Skip to content

Commit

Permalink
Merge pull request #92 from ruurdk/master
Browse files Browse the repository at this point in the history
Automatically adjust part size on upload
  • Loading branch information
vito authored Jan 24, 2018
2 parents 588d61c + 731bb02 commit 245e81b
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 245e81b

Please sign in to comment.