diff --git a/backend/drive/drive.go b/backend/drive/drive.go index f81e98f97..58fb462f6 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -824,7 +824,7 @@ func (f *Fs) PutUnchecked(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOpt } } else { // Upload the file in chunks - info, err = f.Upload(in, size, createInfo.MimeType, createInfo, remote) + info, err = f.Upload(in, size, createInfo.MimeType, "", createInfo, remote) if err != nil { return o, err } @@ -1503,7 +1503,7 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio } } else { // Upload the file in chunks - info, err = o.fs.Upload(in, size, updateInfo.MimeType, updateInfo, o.remote) + info, err = o.fs.Upload(in, size, updateInfo.MimeType, o.id, updateInfo, o.remote) if err != nil { return err } diff --git a/backend/drive/upload.go b/backend/drive/upload.go index 19cda9994..0bf24eb52 100644 --- a/backend/drive/upload.go +++ b/backend/drive/upload.go @@ -53,8 +53,7 @@ type resumableUpload struct { } // Upload the io.Reader in of size bytes with contentType and info -func (f *Fs) Upload(in io.Reader, size int64, contentType string, info *drive.File, remote string) (*drive.File, error) { - fileID := info.Id +func (f *Fs) Upload(in io.Reader, size int64, contentType string, fileID string, info *drive.File, remote string) (*drive.File, error) { params := make(url.Values) params.Set("alt", "json") params.Set("uploadType", "resumable") @@ -67,7 +66,7 @@ func (f *Fs) Upload(in io.Reader, size int64, contentType string, info *drive.Fi if fileID != "" { params.Set("setModifiedDate", "true") urls += "/{fileId}" - method = "PUT" + method = "PATCH" } urls += "?" + params.Encode() var res *http.Response