couldNotUploadFile Error with status code 409: Upload-Offset conflict

オープン
#162 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
supabase, swift
領域
api, mobile

調査の方向性

Start with the TUSKit.TUSAPI upload method and the Supabase resumable-upload endpoint shown in the report. Reproduce the large-file upload while repeatedly backgrounding and foregrounding the phone, inspect the raw 409 response and Upload-Offset values, and determine whether the conflict originates in TUSKit usage or Supabase's implementation.

索引モデルが issue の本文から書いたものです。

説明

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
)
主要言語
Swift
スター
245
フォーク
129
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tus/TUSKit のほかの issue

tus/TUSKit の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。