mirror of
https://github.com/rclone/rclone
synced 2024-11-11 09:30:44 +01:00
drive: fix upload to existing file (#2032)
This fixes uploads to existing files for Google Drive introduced by #2007. Instead of updating the old file a new "Untitled" file would be created in the root folder.
This commit is contained in:
parent
29d428040c
commit
cf6d522d2f
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user