NativeScript / NativeScript/plugins

[background-http] problems uploading images in the background

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

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

主要言語
TypeScript
スター
206
フォーク
123
平均マージ
2日 1時間
マージ済み PR(30日)
1

説明

Hello I'm experiencing problems uploading images in the background when using background-http on iOS.

Here's how I implemented it:

Versions:

"@nativescript/core": "~8.0.0",
"@nativescript/background-http": "^5.0.2",

Implementation:

// filePath is the path to an image
const session = bghttp.session('image-upload')
let file = File.fromPath(filePath)

const params = [
    {
        name: 'files[]',
        filename: filePath,
        mimeType: 'image/jpeg'
    }
]

const task = session.multipartUpload(params, uploadRequestOption)

let data = null
task.on('responded', e => {
    data = e.data
})

task.on('complete', e => {
    if (e.responseCode == 200) {
        responseData = JSON.parse(data)
        // ...
        // ...
        // ...
    }
})

The implementation runs inside a loop.

It worked previously, and I'm not sure when it stopped.
I suspect it happened when I migrated from NS 6 to 8.

This works perfectly fine when the phone is open and the app is active, but when I lock the phone or go out of the app it stops running.
Any help with this is much appreciated.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

まず、示されている iOS バージョンで background-http の session('image-upload') と multipartUpload のエントリーポイントを使用して、報告されたループを再現します。次に、アプリがアクティブな場合と、電話がロックされているかアプリがバックグラウンドにある場合とで動作を比較します。アプリがアクティブでないときに画像のアップロードが継続し、complete イベントが成功レスポンスを受け取れば完了です。

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

評価

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

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

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