From a1323eb20441946bbd575012f39b6ff8b43a5c8b Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 10 Mar 2016 16:48:55 +0000 Subject: [PATCH] s3: Fix uploading files bigger than 50GB - fixes #386 --- s3/s3.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/s3/s3.go b/s3/s3.go index 53eabd3be..d1914d46a 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -761,6 +761,14 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) error { u.Concurrency = 2 u.LeavePartsOnError = false u.S3 = o.fs.c + u.PartSize = s3manager.MinUploadPartSize + size := src.Size() + + // Adjust PartSize until the number of parts is small enough. + if size/u.PartSize >= s3manager.MaxUploadParts { + // Calculate partition size rounded up to the nearest MB + u.PartSize = (((size / s3manager.MaxUploadParts) >> 20) + 1) << 20 + } }) // Set the mtime in the meta data