You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// SaveMultipartFile used in a local Uploader which help to save file in the local path.
func SaveMultipartFile(fh *multipart.FileHeader, path string) (err error) {
var f multipart.File
f, err = fh.Open()
closed := false
if err != nil {
return err
}
defer func() {
if !closed {
if err2 := f.Close(); err2 != nil {
err = err2
}
}
}()
if ff, ok := f.(*os.File); ok {
err = f.Close()
closed = true
dir, name := filepath.Split(path)
return moveFile(ff.Name(), dir, name, true)
}
ff, err := os.Create(path)
if err != nil {
return err
}
defer func() {
if err2 := ff.Close(); err2 != nil {
err = err2
}
}()
_, err = copyZeroAlloc(ff, f)
return err
}
i changed the SaveMultipartFile functions
it has two problems.
os.Rename can't used when 'f' was opened
os.Rename can only used on same disk. if between two harddisk copy, you need used other functions...
otherwise, i want get the filename and filesize when upload a file.
can you add some function to get these two arguments?
i was added these on my local source.
bug 描述 [详细地描述 bug,让大家都能理解]
i used form.File to upload a File.
when the file is very big, this will reponse an error
期望结果 [描述你原本期望看到的结果]
success to upload
复现代码 [提供可复现的代码,仓库,或线上示例]
版本信息:
其他信息 [如截图等其他信息可以贴在这里]
The text was updated successfully, but these errors were encountered: