Alexander Borovoi Alexander Borovoi - 1 year ago 164
reST (reStructuredText) Question

Angular2 image upload with Rest

I have Rest API

I use ng2-file-upload like this

My backend recieves following data

{"file"=>"#<ActionDispatch::Http....bla bla.."}

When i am using rails front end - its ok. I need fix angular2. My backend is waiting data like this:

"photo"=>{"title"=>"qwerty", "image"=> "#<ActionDispatch::Http...blabla..."}

I change

this.alias = uploader.options.itemAlias || 'file';


this.alias = uploader.options.itemAlias || 'image';

But I don't no how append
before form.
I deployed simple backend on heroku

Github apibackend - this
Angular2 deployed - this
. If this problem be fix, I will be start to create my project. Please help.)))

Answer Source

I suggest you take a look at ng2-file-upload.

Just tweak uploader settings and you should be good to go

uploader:FileUploader = new FileUploader({url: URL});

Documentation is a bit incomplete, so take a look at the demo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download