NativeScript / NativeScript/plugins
[background-http] problems uploading images in the background
還沒有人認領這個 Issue。
- 主要語言
- TypeScript
- 星號
- 206
- 分支
- 123
- 平均合併
- 2 天 1 小時
- 30 天內合併 PR
- 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.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先,使用 background-http 的 session('image-upload') 和 multipartUpload 進入點,搭配所示的 iOS 版本重現回報的迴圈,然後比較 App 處於啟用狀態,以及手機鎖定或 App 在背景執行時的行為。當 App 未處於啟用狀態時,圖片上傳仍會繼續,且 complete 事件收到成功回應,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- ios, typescript
- 領域
- mobile
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100