NativeScript / NativeScript/plugins
[@nativescript/background-http] upload error responseCode = -1
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 206
- Forks
- 123
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 1
Description
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);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the multipartUpload call in _uploadBinary with the reported NativeScript CLI, Android, iOS, and Angular versions, then inspect the background-http task error handling for responseCode -1. Compare Android and iOS behavior and determine whether the upload reaches the server; done means identifying the cause and documenting or correcting the error behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, angular, ios, typescript
- Domain
- mobile-dev, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100