-
Notifications
You must be signed in to change notification settings - Fork 124
Open
Description
I'm using TUSKit with Supabase storage (an S3 wrapper), and for the most part it's working fine except the case where I try to upload a large file (~1gb) while repeatedly backgrounding and foregrounding the app on my phone, either by swiping to the Home Screen or locking my phone. It's inconsistent, but after a few times doing that I get a couldNotUploadFile
error with an underlying 409
status code error, and digging into the upload
method in TUSAPI
and printing the raw response data, it says "Upload-Offset conflict".
How can I debug this? Is it an issue with my usage of TUS, the TUSKit iOS SDK itself, or is it possible this is a problem with Supabase's TUS protocol implementation?
Here's the full error:
uploadFailed: couldNotUploadFile(underlyingError: TUSKit.TUSAPIError.failedRequest(<NSHTTPURLResponse: 0x28347f300> { URL: <url> } { Status Code: 409, Headers {
"Access-Control-Allow-Origin" = (
"*"
);
"Alt-Svc" = (
"h3=\":443\"; ma=86400"
);
"Content-Length" = (
23
);
Date = (
"Wed, 31 May 2023 16:14:12 GMT"
);
Server = (
cloudflare
);
"Strict-Transport-Security" = (
"max-age=2592000; includeSubDomains"
);
Vary = (
"Accept-Encoding"
);
"access-control-expose-headers" = (
"Authorization, Content-Type, Location, Tus-Extension, Tus-Max-Size, Tus-Resumable, Tus-Version, Upload-Concat, Upload-Defer-Length, Upload-Length, Upload-Metadata, Upload-Offset, X-HTTP-Method-Override, X-Requested-With, X-Forwarded-Host, X-Forwarded-Proto, Forwarded, Upload-Expires"
);
"cf-cache-status" = (
DYNAMIC
);
"cf-ray" = (
"7d0082268c553344-EWR"
);
"sb-gateway-mode" = (
direct
);
"sb-gateway-version" = (
1
);
"tus-resumable" = (
"1.0.0"
);
} }))
Here's how I'm using TUS:
let tusEndpoint = Environment.SUPABASE_URL.appendingPathComponent("storage/v1/upload/resumable")
self.tusClient = try TUSClient(
server: tusEndpoint,
sessionIdentifier: "media-upload-queue",
chunkSize: 6 * 1024 * 1024
)
let context: [String : String] = {
var context: [String : String] = [:]
if let mimeType = self.mimeType(forFile: fileURL) {
context["contentType"] = mimeType
}
context["bucketName"] = <bucketName
context["objectName"] = <fileName>
return context
}()
let headers: [String : String] = {
var headers: [String : String] = [:]
headers["authorization"] = "Bearer <token>"
headers["x-upsert"] = "true"
return headers
}()
try self.tusClient.uploadFileAt(
filePath: fileURL,
customHeaders: headers,
context: context
)
Metadata
Metadata
Assignees
Labels
No labels