Skip to content

Commit

Permalink
File size for dropped files added.
Browse files Browse the repository at this point in the history
  • Loading branch information
palakrathi committed Sep 2, 2020
1 parent f57b301 commit ad54f5b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kubric/asset-uploader",
"version": "0.0.8",
"version": "0.0.9",
"description": "Upload assets to the kubric asset system",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
Expand Down
22 changes: 13 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ const MAX_CHUNKSIZE = 104857600;
export const events = uploaderEvents;

const addFileSizes = files => {
const mappedFiles = files.map(file => {
if (file.size) {
return file['_parsedSize'] = getHumanFileSize(file.size)
} else {
file.file(fl => file['_parsedSize'] = getHumanFileSize(fl.size));
return file;
}
});
return mappedFiles;
return Promise.all(files.map(file => {
return new Promise(resolveFile => {
if (file.size) {
file['_parsedSize'] = getHumanFileSize(file.size);
resolveFile(file);
} else {
file.file(fl => {
file['_parsedSize'] = getHumanFileSize(fl.size)
resolveFile(file);
});
}
})
}))
}

const validateDataTransfer = (obj = {}) => {
Expand Down

0 comments on commit ad54f5b

Please sign in to comment.