Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

b2: fix uploading empty files with go1.8

Nick Craig-Wood175c39e1d044
diff --git a/b2/b2.go b/b2/b2.go
index 9f928898e..5fa669973 100644
--- a/b2/b2.go
+++ b/b2/b2.go
@@ -1292,6 +1292,11 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) (err error) {
},
ContentLength: &size,
}
+ // for go1.8 (see release notes) we must nil the Body if we want a
+ // "Content-Length: 0" header which b2 requires for all files.
+ if size == 0 {
+ opts.Body = nil
+ }
var response api.FileInfo
// Don't retry, return a retry error instead
err = o.fs.pacer.CallNoRetry(func() (bool, error) {