jaydenseric / extract-files

A function to recursively extract files and their object paths within a value, replacing them with null in a deep clone without mutating the original value. FileList instances are treated as File instance arrays. Files are typically File and Blob instances.
https://npm.im/extract-files
MIT License
56 stars 23 forks source link

Support Blob type #2

Closed ArtNattapat closed 6 years ago

ArtNattapat commented 7 years ago

IE11 not support new File(). must use Blob instead.

jaydenseric commented 7 years ago

Thanks for the PR 🙂

A heads-up that I won't have the time to properly review this for at least the next few days.

A brief, but related conversation: https://github.com/jaydenseric/apollo-upload-client/issues/28#issuecomment-320863665.

ArtNattapat commented 7 years ago

ie11 and edge can't create file with new File(['test file'], 'test.txt') i think this just workaround for ie11 and edge(not support too) if need to upload blob. or will be a shorthand upload by blob (not need to new File()). but disadvantage on Blob is have no filename, and mine type like you told on related conversation.

my english is not good, sorry 🙁

jaydenseric commented 7 years ago

That's ok about the english 🙂

Because blobs are a little different to files this PR needs to be closely reviewed and tested across 4 related packages (extract-files, apollo-upload-client, apollo-fetch-upload, apollo-upload-server). Documentation across all would need to be updated. I am spread really thin for time right now, and because I don't need to support blobs for current deadlines this will just have to wait a while to be merged.

ArtNattapat commented 7 years ago

I got it. thank you ^^

keeth commented 6 years ago

It seems I need Blob support too. I'm building a File object manually (from data URI after cropping an image), not using one from the File API.

Here's a minimal case that illustrates the problem. I found that the following seems to work in Chrome but not in Webkit:

var fd = new FormData(); 
fd.append('foo', new File(['abcd'], 'foo'));
fetch('http://mockbin.org/echo', {method:'POST', mode: 'cors', body: fd});

In Webkit, the 'foo' part body is empty.

However this works in both (using Blob instead of file):

var fd = new FormData(); 
fd.append('foo', new Blob(['abcd']));
fetch('http://mockbin.org/echo', {method:'POST', mode: 'cors', body: fd});
jaydenseric commented 6 years ago

I've been crazy busy with gen 2 uploads, which are are now in alpha. Other than preparing stable releases, this, along with https://github.com/jaydenseric/extract-files/issues/3 is my next priority.

jaydenseric commented 6 years ago

Thanks for looking into this, I tried to merge this before https://github.com/jaydenseric/extract-files/pull/5 so you would be included in the contributors list, but there were too many conflicts with the current master branch. Blob support is on the way!