mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 03:48:27 +08:00
zoho: attempt to fix large file upload - not working DO NOT MERGE
This commit is contained in:
parent
3933b1e7f5
commit
a2f55eccbc
|
@ -670,27 +670,28 @@ func isSimpleName(s string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Fs) upload(ctx context.Context, name string, parent string, size int64, in io.Reader, options ...fs.OpenOption) (*api.Item, error) {
|
func (f *Fs) upload(ctx context.Context, name string, parent string, size int64, in io.Reader, options ...fs.OpenOption) (*api.Item, error) {
|
||||||
params := url.Values{}
|
uploadID := random.String(20) // random upload ID
|
||||||
params.Set("filename", name)
|
|
||||||
params.Set("parent_id", parent)
|
|
||||||
params.Set("override-name-exist", strconv.FormatBool(true))
|
|
||||||
formReader, contentType, overhead, err := rest.MultipartUpload(ctx, in, nil, "content", name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to make multipart upload: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
contentLength := overhead + size
|
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Path: "/upload",
|
//RootURL: "https://upload.zoho.com/workdrive-api/v1",
|
||||||
Body: formReader,
|
RootURL: "https://upload.zoho.eu/workdrive-api/v1",
|
||||||
ContentType: contentType,
|
Path: "/stream/upload",
|
||||||
ContentLength: &contentLength,
|
Body: in,
|
||||||
Options: options,
|
ContentType: fs.MimeTypeFromName(name), // FIXME should read mime type of original object
|
||||||
Parameters: params,
|
ContentLength: &size,
|
||||||
TransferEncoding: []string{"identity"},
|
Options: options,
|
||||||
|
ExtraHeaders: map[string]string{
|
||||||
|
"x-filename": name,
|
||||||
|
"x-parent_id": parent,
|
||||||
|
"upload-id": uploadID,
|
||||||
|
"x-streammode": "1",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if size < 0 {
|
||||||
|
opts.ContentLength = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
var uploadResponse *api.UploadResponse
|
var uploadResponse *api.UploadResponse
|
||||||
err = f.pacer.CallNoRetry(func() (bool, error) {
|
err = f.pacer.CallNoRetry(func() (bool, error) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user