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 1 commit
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
12 changes: 10 additions & 2 deletions src/resources/assets/js/createContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import DirectoriesApi from './api/storageRequestDirectories';
import FilesApi from './api/storageRequestFiles';
import StorageRequestApi from './api/storageRequests';
import {LoaderMixin, handleErrorResponse, FileBrowserComponent} from './import';
import {LoaderMixin, handleErrorResponse, FileBrowserComponent, warning} from './import';
import {sizeForHumans} from './utils';

// Number of times a file upload is retried.
Expand Down Expand Up @@ -126,7 +126,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(' ')) {
let newName = newFiles[i].name.replace(' ', '_');
mzur marked this conversation as resolved.
Show resolved Hide resolved
file = new File([newFiles[i]], newName, { type: newFiles[i].type })
warning('Spaces are replaced by underscores in file names');
mzur marked this conversation as resolved.
Show resolved Hide resolved
}
files.push(file);
}

this.syncFiles();
Expand Down
1 change: 1 addition & 0 deletions src/resources/assets/js/import.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export let FileBrowserComponent = biigle.$require('core.components.fileBrowser');
export let handleErrorResponse = biigle.$require('messages').handleErrorResponse;
export let warning = biigle.$require('messages').warning;
export let LoaderMixin = biigle.$require('core.mixins.loader');