Skip to content

Commit

Permalink
* Use !isFile() instead of !(state.file instanceof Blob) when det…
Browse files Browse the repository at this point in the history
…ermining if a file has loaded, since in my testing, Edge is presenting a `File` object at this stage, rather than the `Blob` that Chrome etc are presenting (fixes pqina#507).

* If `createFileProcessorFunction` is presented with a file object that is not of type `Blob` (such as `File`, as seen in Edge browser), it attempts to iterate over it using `forEach` as if it were an iterable object, however `File` objects do not have a `forEach` method. Resolve this by treating all file object input into this function as though they are a singular, non-iterable object (fixes pqina#507).

* Fix comment typo.
  • Loading branch information
dannya committed May 26, 2020
1 parent cbd8b6d commit 2401d02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/js/app/utils/createFileProcessorFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const createFileProcessorFunction = (apiUrl, action, name, options) => (f
if (isObject(metadata)) { formData.append(name, JSON.stringify(metadata)); }

// Turn into an array of objects so no matter what the input, we can handle it the same way
(file instanceof Blob ? [{ name: null, file }] : file).forEach(item => {
[{ name: null, file }].forEach(item => {
formData.append(name, item.file, item.name === null ? item.file.name : `${item.name}${item.file.name}`);
});

Expand Down
4 changes: 2 additions & 2 deletions src/js/app/utils/createItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const createItem = (origin = null, serverFileReference = null, file = nul
fire('load-init');
});

// we'eve received a size indication, let's update the stub
// we've received a size indication, let's update the stub
loader.on('meta', meta => {

// set size of file stub
Expand Down Expand Up @@ -226,7 +226,7 @@ export const createItem = (origin = null, serverFileReference = null, file = nul
abortProcessingRequestComplete = null;

// if no file loaded we'll wait for the load event
if (!(state.file instanceof Blob)) {
if (!isFile(state.file)) {
api.on('load', () => {
process(processor, onprocess);
});
Expand Down

0 comments on commit 2401d02

Please sign in to comment.