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