How to use the ember-file-upload/mirage.upload function in ember-file-upload

To help you get started, we’ve selected a few ember-file-upload examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adopted-ember-addons / ember-file-upload / tests / dummy / mirage / config.js View on Github external
export default function () {
  this.passthrough(`${config.rootURL}write-coverage`);
  this.passthrough(`${config.rootURL}versions.json`);
  this.passthrough(`${config.rootURL}docs/ember-file-upload.json`);
  this.passthrough(`${config.rootURL}ember-cli-addon-docs/search-index.json`);
  this.passthrough(`${config.rootURL}ember-cli-addon-docs/versions/:version/search-index.json`);

  this.post('/photos/new', upload(function (db, request) {
    let { type, name, size, url } = request.requestBody.file;
    return db.create('photo', {
      filename: name,
      filesize: size,
      uploadedAt: new Date(),
      url,
      type: type.split('/')[0]
    });
  }));
}