I'm using the demo-server from nativescript-background-http and have setup a demo app which sends an image captured by the phones camera to the backend.
sendPicture(filepath) {
var url = "http://192.168.200.4:8080"; // Demo server, works
var name = filepath.substr(filepath.lastIndexOf("/") + 1);
console.log("FILE: " + filepath);
// upload configuration
var bghttp = require("nativescript-background-http");
var session = bghttp.session("image-upload");
var request = {
url: url,
method: "POST",
headers: {
"file-name": name,
"Content-Type": "application/octet-stream"
},
description: "Uploading " + name
};
var params = [
{
name: name,
filename: filepath,
mimeType: "image/jpeg"
}
];
var task = session.multipartUpload(params, request);
task.on("error", this.errorHandler);
task.on("responded", this.respondedHandler);
task.on("complete", this.completeHandler);
}
The end result of the image has meta data around it which I have to remove so that I can view it in a image previewing program.
---------AndroidUploadService7465829660026
Content-Disposition: form-data; name="NSIMG_20190827_14127.jpg"; filename="NSIMG_20190827_14127.jpg"
Content-Type: image/jpeg
<The picture binary blob>
---------AndroidUploadService7465829660026--
Why is the demo-server putting this meta data in the uploaded file?