From 6474f2c7c254417878d07765279f37b14c154325 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 15 Mar 2017 12:45:03 +0000 Subject: [PATCH] onedrive: fix uploading empty files with go1.8 --- onedrive/onedrive.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/onedrive/onedrive.go b/onedrive/onedrive.go index fb810fddf..c82bcc3f0 100644 --- a/onedrive/onedrive.go +++ b/onedrive/onedrive.go @@ -1024,6 +1024,11 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) (err error) { Path: "/drive/root:/" + url.QueryEscape(o.srvPath()) + ":/content", Body: in, } + // for go1.8 (see release notes) we must nil the Body if we want a + // "Content-Length: 0" header which onedrive requires for all files. + if size == 0 { + opts.Body = nil + } err = o.fs.pacer.CallNoRetry(func() (bool, error) { resp, err = o.fs.srv.CallJSON(&opts, nil, &info) return shouldRetry(resp, err)