From 175c39e1d0442d51c0906caf809e3b3c93fc0c37 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 25 Feb 2017 15:22:14 +0000 Subject: [PATCH] b2: fix uploading empty files with go1.8 --- b2/b2.go | 5 +++++ 1 file changed, 5 insertions(+) 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) {