NativeScript / NativeScript/plugins
[@nativescript/background-http] upload error responseCode = -1
未关闭
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 206
- 派生
- 123
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 1
描述
Please, provide the following version numbers that your issue occurs with:
CLI: 7.0.10
"@nativescript/android": "7.0.1",
"@nativescript/ios": "7.0.5",
angular 10.2.1
When I upload a file, I get the error below.
e.responseCode = -1
this is my code
public _uploadBinary(fileName: string) {
this.file = fileName;
const name = this.file.substr(this.file.lastIndexOf('/') + 1);
const description = `${name}`;
const request = {
url: this.avatarUrl,
method: 'POST',
headers: {
"Content-Type": "application/octet-stream",
"File-Name": name,
"Authorization": `Bearer ${this.authTokenService.token}`
},
description: description,
androidAutoDeleteAfterUpload: true,
androidNotificationTitle: 'NativeScript HTTP background',
};
let task: Task;
var params = [{name: name, value: "value"}, {name:"fileToUpload", filename: this.file, mimeType: 'image/jpeg'}];
task = this.session.multipartUpload(params, request);
task.on("progress", (e) => {
console.log("upload progress", JSON.stringify(e));
});
task.on("error", (e) => {
console.log("upload error", JSON.stringify(e));
alert("error received " + e.responseCode + " code.");
});
task.on("responded", (e) => {
console.log("responded", JSON.stringify(e) );
console.log("responded data", JSON.stringify(e.data) );
});
task.on("complete", (e) => {
console.log("upload complete", JSON.stringify(e));
});
this.tasks.push(task);
}
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用报告中的 NativeScript CLI、Android、iOS 和 Angular 版本,复现 _uploadBinary 中的 multipartUpload 调用,然后检查 background-http 任务对 responseCode -1 的错误处理。比较 Android 和 iOS 的行为,并确定上传是否到达服务器;完成的标准是确定原因并记录或修正错误行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, angular, ios, typescript
- 领域
- mobile-dev, networking
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100