Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

linkbox: fix upload error "user upload file not exist"

Nick Craig-Wood87a65ec6a5a5
diff --git a/backend/linkbox/linkbox.go b/backend/linkbox/linkbox.go
index fd849ef59..4537d657e 100644
--- a/backend/linkbox/linkbox.go
+++ b/backend/linkbox/linkbox.go
@@ -617,16 +617,36 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
case 1:
// upload file using link from first step
var res *http.Response
+ var location string
- file := io.MultiReader(bytes.NewReader(first10mBytes), in)
-
+ // Check to see if we are being redirected
opts := &rest.Opts{
- Method: "PUT",
- RootURL: getFirstStepResult.Data.SignURL,
- Options: options,
- Body: file,
- ContentLength: &size,
+ Method: "HEAD",
+ RootURL: getFirstStepResult.Data.SignURL,
+ Options: options,
+ NoRedirect: true,
}
+ err = o.fs.pacer.CallNoRetry(func() (bool, error) {
+ res, err = o.fs.srv.Call(ctx, opts)
+ return o.fs.shouldRetry(ctx, res, err)
+ })
+ if res != nil {
+ location = res.Header.Get("Location")
+ if location != "" {
+ // set the URL to the new Location
+ opts.RootURL = location
+ err = nil
+ }
+ }
+ if err != nil {
+ return fmt.Errorf("head upload URL: %w", err)
+ }
+
+ file := io.MultiReader(bytes.NewReader(first10mBytes), in)
+
+ opts.Method = "PUT"
+ opts.Body = file
+ opts.ContentLength = &size
err = o.fs.pacer.CallNoRetry(func() (bool, error) {
res, err = o.fs.srv.Call(ctx, opts)