Skip to content

Commit

Permalink
Merge pull request #24 from biigle/spaces-in-filename-bug
Browse files Browse the repository at this point in the history
Replace spaces by underscores in file names
  • Loading branch information
mzur authored Jan 11, 2024
2 parents 53cbe1f + e4bf8a4 commit b1d3b79
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/public/assets/scripts/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/assets/scripts/main.js": "/assets/scripts/main.js?id=7d6da521ca619780e6f73426bf5eeee7",
"/assets/scripts/main.js": "/assets/scripts/main.js?id=018be3d59bf625225047d17d0c2fd60f",
"/assets/styles/main.css": "/assets/styles/main.css?id=16bca02d88eeae2a4e45dba3d77b7757"
}
15 changes: 14 additions & 1 deletion src/resources/assets/js/createContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default {
maxFilesizeBytes: 0,
exceedsMaxFilesize: false,
chunkSize: 0,
pathContainsSpaces: false,
};
},
computed: {
Expand Down Expand Up @@ -126,7 +127,15 @@ export default {
}
for (i = 0; i < newFiles.length; i++) {
files.push(newFiles[i]);
// Replace spaces by underscores in file name due to error when uploading files >5GB.
// See https://github.com/biigle/user-storage/issues/16.
let file = newFiles[i];
if (file.name.includes(' ')) {
this.pathContainsSpaces = true;
let newName = newFiles[i].name.replace(/ /g, '_');
file = new File([newFiles[i]], newName, { type: newFiles[i].type });
}
files.push(file);
}
this.syncFiles();
Expand Down Expand Up @@ -168,6 +177,10 @@ export default {
addDirectory(root) {
let name = prompt('Please enter the new directory name');
if (name) {
if (name.includes(' ')) {
this.pathContainsSpaces = true;
name = name.replace(/ /g, '_');
}
this.handleNewDirectory(name, root === true);
}
},
Expand Down
4 changes: 4 additions & 0 deletions src/resources/views/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class="btn btn-success"
Selected files with a total size of <span v-text="totalSizeForHumans"></span>.
</p>

<p v-cloak v-if="pathContainsSpaces" class="text-warning">
Spaces in the file and directory names were replaced by underscores.
</p>

<file-browser
v-cloak
v-bind:root-directory="rootDirectory"
Expand Down

0 comments on commit b1d3b79

Please sign in to comment.