Merge pull request #1348 from SkynetLabs/undefined-dir-upload-name-and-empty-progress
fix undefined dir upload name and empty progress
This commit is contained in:
commit
905dd7ecb9
|
@ -0,0 +1,2 @@
|
|||
- fixed uploaded directory name (was "undefined" before)
|
||||
- fixed empty directory upload progress (size was not calculated for directories)
|
|
@ -47,8 +47,9 @@ const Uploader = () => {
|
|||
const handleDrop = async (files) => {
|
||||
if (mode === "directory" && files.length) {
|
||||
const name = getRootDirectory(files[0]); // get the file path from the first file
|
||||
const size = files.reduce((acc, file) => acc + file.size, 0);
|
||||
|
||||
files = [{ name, files }];
|
||||
files = [{ name, size, files }];
|
||||
}
|
||||
|
||||
setUploads((uploads) => [...files.map((file) => ({ id: nanoid(), file, mode, status: "enqueued" })), ...uploads]);
|
||||
|
|
|
@ -85,7 +85,7 @@ export default function UploaderElement({ onUploadStateChange, upload }) {
|
|||
if (upload.mode === "directory") {
|
||||
const files = upload.file.files;
|
||||
const directory = files.reduce((acc, file) => ({ ...acc, [getRelativeFilePath(file)]: file }), {});
|
||||
const name = encodeURIComponent(upload.name);
|
||||
const name = encodeURIComponent(upload.file.name);
|
||||
|
||||
response = await client.uploadDirectory(directory, name, { onUploadProgress });
|
||||
} else {
|
||||
|
|
Reference in New Issue