Closed samliaw closed 7 years ago
This issue was moved to NativeScript/nativescript-background-http#61
Hi,
I spend some more time to debug and finally confirm what cause the issue. Please look at the code in the component. I simply change the lowercase "post" to all uppercase "POST" and it works perfectly.
hopefully this will help other people who face similar issue like me.
let request = {
url: "http://it-enable.net:9191/file",
method: "post", //<----- change post to POST solve the issue
headers: {
"Content-Type": "application/octet-stream",
"File-name": filename
},
description: "{ 'uploading': '" + filename + "' }"
}
Hi, I am testing nativescript-background-http to test upload a picture file to server.
I test using physical mobile device. Below is the coding file ==================================start of a.component.ts================================
==================================end of a.component.ts================================
==================================start of package.json================================
==================================end of package.json================================
I am using the node.js restify to accept the file. I have tested using Postman and it works file. The code of the restify is as below ==================================start of restify index.js================================
==================================end of restify index================================
==================================start of restify packson.json================================
==================================endof restify packson.json================================
When I use the Postman, I provide the following attirbutes Method: Post URL: http://it-enable.net:9191/file Header: {"Content-Type":"application/octet-stream"} Attached a picture file.
If the file is uploaded successfully, I can see the response of "Done!".
When I run the project in physical mobile device, I hit the error "error during upload." When I look at backend restify, I find that the nativescript-background-http hits error before it sends the file to backend restify. This is because the backend restify doesn't inidicate it has receives any file.
I do test this whole afternoon but to no vail. I copy the source code that people have claim successful executing but it doesn't work for me. There is no detail error code so I am not able to figure what is wrong.
Any suggestion or method is welcomed.