Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace spaces by underscores in file names #24

Merged
merged 7 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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">
Replaced spaces by underscores.
mzur marked this conversation as resolved.
Show resolved Hide resolved
</p>

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