mardi 6 septembre 2016

ember uploader authentication help please

I am very new to all of this!

Hi, I am trying to upload an image to a rails api from an ember app. I have installed the ember uploader addon and my url is correct(works perfectly through postman), but I am having problems with authentication.

The app itself is set up with devise and the routes all have authenticatedRouteMixin and the adaptors have the dataAdaptorMixin which automatically take care of the authenticaton.

I am struggling to inject authentication into the the call to the api. Any help would be appreciated. My call to the api currently looks like this. An extra argument can go at (files[0],{extraArgument}) but not sure if this is even where I should be putting authentication details or how to access them.

export default EmberUploader.FileField.extend({

  filesDidChange: function(files) {
    const uploader = EmberUploader.Uploader.create({
      url: this.get('url'),
      method: 'PUT',


    });

    if (!Ember.isEmpty(files)) {
      data with the upload
      uploader.upload(files[0]);
    }
  }
});




Aucun commentaire:

Enregistrer un commentaire