rest: no copy file download

This commit is contained in:
criyle 2024-02-03 15:49:32 +00:00
parent 8025bd36b6
commit c29d0adce2
2 changed files with 10 additions and 3 deletions

View File

@ -67,6 +67,15 @@ func (f *fileHandle) fileIDGet(c *gin.Context) {
c.AbortWithStatus(http.StatusNotFound)
return
}
typ := mime.TypeByExtension(path.Ext(name))
c.Header("Content-Type", typ)
fi, ok := file.(*envexec.FileInput) // fast path
if ok {
c.FileAttachment(fi.Path, name)
return
}
r, err := envexec.FileToReader(file)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
@ -79,8 +88,6 @@ func (f *fileHandle) fileIDGet(c *gin.Context) {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
typ := mime.TypeByExtension(path.Ext(name))
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", name))
c.Data(http.StatusOK, typ, content)
}

View File

@ -251,7 +251,7 @@ func (e *Environment) Execve(ctx context.Context, param envexec.ExecveParam) (pr
result.ExitStatus = int(exitCode)
// collect usage
t, m, err := getJobOjbectUsage(hJob)
t, m, err := getJobObjectUsage(hJob)
if err != nil {
procSet.result = runner.Result{Status: runner.StatusRunnerError, Error: err.Error()}
return