NativeScript / NativeScript/plugins
[@nativescript/background-http] upload error responseCode = -1
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 206
- Fork
- 123
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
Mô tả
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);
}
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện lệnh gọi multipartUpload trong _uploadBinary với các phiên bản NativeScript CLI, Android, iOS và Angular được báo cáo, sau đó kiểm tra việc xử lý lỗi của tác vụ background-http đối với responseCode -1. So sánh hành vi trên Android và iOS và xác định liệu quá trình tải lên có đến được máy chủ hay không; công việc được xem là hoàn tất khi đã xác định nguyên nhân và ghi lại hoặc sửa hành vi lỗi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android, angular, ios, typescript
- Lĩnh vực
- mobile-dev, networking
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100