How to use ember-file-upload - 7 common examples

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 / addon / mirage / utils.js View on Github external
gif(file) {
    let reader = new FileReader();
    return reader.readAsArrayBuffer(file).then(function (buffer) {
      let data = new Uint8Array(buffer);
      let duration = 0;
      for (let i = 0; i < data.length; i++) {
        // Find a Graphic Control Extension hex(21F904__ ____ __00)
        if (data[i] === 0x21 &&
            data[i + 1] === 0xF9 &&
            data[i + 2] === 0x04 &&
            data[i + 7] === 0x00) {
          // Swap 5th and 6th bytes to get the delay per frame
          let delay = (data[i + 5] << 8) | (data[i + 4] & 0xFF);

          // Should be aware browsers have a minimum frame delay
          // e.g. 6ms for IE, 2ms modern browsers (50fps)
          duration += delay < 2 ? 10 : delay;
        }
github NYCPlanning / labs-zap-search / app / controllers / my-projects / assignment / recommendations / add.js View on Github external
const copyCompletionStatuses = this.dispositions.map(async (disposition) => {
      // use this private/undocument .blob property to duplicate the file
      const fileCopy = await File.fromBlob(file.blob);
      this.queuesByDisposition[disposition.id].push(fileCopy);
      return true;
    });
    const resolvedStatuses = await Promise.all(copyCompletionStatuses);
github adopted-ember-addons / ember-file-upload / addon / mirage / shim.js View on Github external
import uuid from 'ember-file-upload/system/uuid';

const MAP = 'map_' + uuid.short();
const KEYS = 'keys_' + uuid.short();

// Handle support for FormData#get in browsers that don't
// support it, only be done when mirage is included.
// Specifically, PhantomJS 👻
if (FormData.prototype.get == null) {
  const append = FormData.prototype.append;
  FormData.prototype.append = function (...args) {
    if (this[MAP] == null) { this[MAP] = {}; }
    if (this[KEYS] == null) { this[KEYS] = []; }
    this[MAP][args[0]] = args[1];
    this[KEYS].push(args[0]);
    return append.call(this, ...args);
  };

  FormData.prototype.get = function (key) {
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]
    });
  }));
}
github adopted-ember-addons / ember-file-upload / addon / mirage / utils.js View on Github external
export function extractFileMetadata(file) {
  let metadata = {
    name: file.name,
    size: file.size,
    type: file.type,
    extension: (file.name.match(/\.(.*)$/) || [])[1]
  };

  let reader = new FileReader();
  return reader.readAsDataURL(file).then(function (url) {
    metadata.url = url;

    let additionalMetadata = [];

    if (metadata.type === 'image/gif') {
      additionalMetadata.push(pipelines.gif(file, metadata));
    }
    if (metadata.type.match(/^image\//)) {
      additionalMetadata.push(pipelines.image(file, metadata));
    }
    if (metadata.type.match(/^video\//)) {
      additionalMetadata.push(pipelines.video(file, metadata));
    }
    if (metadata.type.match(/^audio\//)) {
      additionalMetadata.push(pipelines.audio(file, metadata));
github mnutt / davros / app / components / davros-uploader / component.js View on Github external
import fileDropzone from 'ember-file-upload/components/file-dropzone/component';
import DragListener from 'ember-file-upload/system/drag-listener';
import Ember from 'ember';

const { get } = Ember;
const { bind } = Ember.run;

const dragListener = new DragListener();

export default fileDropzone.extend({
  didInsertElement() {
    this._super();

    if (get(this, 'fullscreen')) {
      dragListener.addEventListeners('body', {
        dragenter: bind(this, 'didEnterDropzone'),
        dragleave: bind(this, 'didLeaveDropzone'),
        dragover:  bind(this, 'didDragOver'),
        drop:      bind(this, 'didDrop')
      });
    }
  },

  willDestroyElement() {
    this._super();
github mnutt / davros / app / components / davros-uploader / component.js View on Github external
import fileDropzone from 'ember-file-upload/components/file-dropzone/component';
import DragListener from 'ember-file-upload/system/drag-listener';
import Ember from 'ember';

const { get } = Ember;
const { bind } = Ember.run;

const dragListener = new DragListener();

export default fileDropzone.extend({
  didInsertElement() {
    this._super();

    if (get(this, 'fullscreen')) {
      dragListener.addEventListeners('body', {
        dragenter: bind(this, 'didEnterDropzone'),
        dragleave: bind(this, 'didLeaveDropzone'),
        dragover:  bind(this, 'didDragOver'),
        drop:      bind(this, 'didDrop')
      });
    }
  },

  willDestroyElement() {