Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to skip form data insertion (won't change default functionality) #163

Open
ioan-pop opened this issue Jul 27, 2017 · 3 comments

Comments

@ioan-pop
Copy link

ioan-pop commented Jul 27, 2017

The extra form data that is inserted for files can cause issues on the other hand, I suggest adding a optional property of "skipFormData" (Boolean) to the uploader object. Example:

const uploader = EmberUploader.Uploader.create({
    url: this.get('url'),
    method: "PATCH",
    skipFormData: true
);

Then inside the /addon/uploaders/base.js on line 63 the data can be changed to be:

const data   = !get(this, 'skipFormData') ? this.createFormData(files, extra) : files;

This will skip the form data if the property is set to true, and create the form data if the property is set to false, or is not present.

@digitaltoad
Copy link
Member

I guess I don't really understand the problem here. There should be a single FormData. FormData is required (afaik but please do correct me if I'm wrong as I would like to know) for upload via JS.

@ioan-pop
Copy link
Author

ioan-pop commented Aug 8, 2017

Hey digitaltoad, you're right, this issue can be closed. Thanks!

@ezekg
Copy link

ezekg commented Aug 7, 2018

As mentioned in #147, form data is not required, and messes with uploads that should be a binary upload. For example, AWS S3 doesn't support form data (and I'm not sure how it's working for other people, to be honest). I'm using this modified uploader below to be able to upload to S3:

import EmberUploader from 'ember-uploader'
import Ember from 'ember'

const { Uploader } = EmberUploader
const { get, set } = Ember

const BinaryUploader = Uploader.extend({
  upload(file) {
    const url    = get(this, 'url')
    const method = get(this, 'method')

    set(this, 'isUploading', true)

    return this.ajax(url, file, method)
  }
})

I was seeing issues where the uploader would send multipart/form-data, and that data would be stored raw in S3 (including the data boundaries), causing files to become corrupted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants