dimanche 19 février 2017

404 error on Ember file upload

I'm trying to upload a file with Ember.js. I have tried two plugins:

ember-file-upload and ember-uploader

Normally I would post my question on the appropriate github page, but I am getting the same error with both, so I suspect it is something I am doing and not an issue with the plugins themselves.

I have a folder called "uploads" in my public folder which I'm trying to save my file to. However, when I try to upload a file using either plugin, I get this error:

POST http://localhost:4200/uploads 404 (Not Found)

This is my my template with the component:



This is the component js:

import EmberUploader from 'ember-uploader';

export default EmberUploader.FileField.extend({
  filesDidChange: function(files) {
    const uploader = EmberUploader.Uploader.create({
      url: this.get('url'),
    });

    if (!Ember.isEmpty(files)) {
      // this second argument is optional and can to be sent as extra data with the upload
      uploader.upload(files[0]);
    }
  }
});

I have also tried to direct it to my assets folder as well as a folder called "files" within assets. I have tried absolute paths as well and I still get a 404. I 100% know that those folders exist because they show up in dist. Do I need to use a different path? Is there something else I have to set up that will allow that folder to be found?




Aucun commentaire:

Enregistrer un commentaire