Skip to content

Commit

Permalink
Automatically adjust part size on upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ruurdk committed Jan 17, 2018
1 parent 588d61c commit 731bb02
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion s3client.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,18 @@ func (client *s3client) UploadFile(bucketName string, remotePath string, localPa
}

defer localFile.Close()

// Automatically adjust partsize for larger files.
fSize := stat.Size()
if fSize > int64(uploader.MaxUploadParts) * uploader.PartSize {
partSize := fSize / int64(uploader.MaxUploadParts)
if fSize % int64(uploader.MaxUploadParts) != 0 {
partSize++
}
uploader.PartSize = partSize
}

progress := client.newProgressBar(stat.Size())
progress := client.newProgressBar(fSize)

progress.Start()
defer progress.Finish()
Expand Down

0 comments on commit 731bb02

Please sign in to comment.