How to upload an image

plugins

#1

I’m trying to upload an image via nativescript-background-http plugin.

this my code:

var session = bghttp.session("image-upload");
var request = {
  url: 'http://localhost:4200/',
  method: "POST",
  headers: {
    "Content-Type": "application/octet-stream",
    "File-Name": imageFile.name
  },
  description: "{ 'uploading': " + imageFile.name + " }"
};

var task = this.session.uploadFile(path, request);

when I try to build my app, it will show the error:

TypeError: Cannot set property 'NAMESPACE' of undefined

The line of error is exactly this line:

var task = this.session.uploadFile(path, request);

any idea?


#2

That sounds like your dependencies were not installed properly, try a clean build.


#3

Finally, I could upload images without using nativescript-background-http plugin.
Anyway thanks