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 版本,复现报告中的循环;然后比较应用处于活动状态时,以及手机锁定或应用处于后台时的行为。当应用不处于活动状态时,图像上传仍能继续,且 complete 事件收到成功响应,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- ios, typescript
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100