Skip to content

Commit

Permalink
support large file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
huangnauh committed Feb 11, 2025
1 parent 38d6b20 commit 5a77d4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ func (sess *Session) putFileWithProgress(localPath, upPath string, localInfo os.
}
if localInfo.Size() >= MinResumePutFileSize || sess.multipart {
cfg.UseResumeUpload = true
cfg.ResumePartSize = DefaultBlockSize
cfg.ResumePartSize = ResumePartSize(localInfo.Size())
cfg.MaxResumePutTries = DefaultResumeRetry
}

Expand Down
16 changes: 16 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ func isWindowsGOOS() bool {
return runtime.GOOS == "windows"
}

func ResumePartSize(size int64) int64 {
if size < 50*1024*1024 {
return 1024 * 1024
}

if size < 1024*1024*1024 {
return 10 * 1024 * 1024
}

if size < 100*1024*1024*1024 {
return 50 * 1024 * 1024
}

return 100 * 1024 * 1024
}

func cleanFilename(name string) string {
if !isWindowsGOOS() {
return name
Expand Down

0 comments on commit 5a77d4e

Please sign in to comment.