mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 13:49:57 -05:00
A user can overwrite existing files when uploading.
This commit is contained in:
parent
3d6ccad0c0
commit
fab3fd62ed
5 changed files with 114 additions and 9 deletions
|
|
@ -1153,6 +1153,7 @@ export const useUploadFile = () => {
|
|||
const [progresses, setProgresses] = useState({});
|
||||
const [destination, setDestination] = useState('');
|
||||
const [tagNames, setTagNames] = React.useState([]);
|
||||
const [overwrite, setOverwrite] = React.useState(false);
|
||||
|
||||
const handleProgress = (name, chunk, totalChunks, status, type) => {
|
||||
const percent = Math.round((100 * chunk) / totalChunks);
|
||||
|
|
@ -1184,6 +1185,9 @@ export const useUploadFile = () => {
|
|||
formData.append('filename', file.path);
|
||||
formData.append('totalChunks', totalChunks.toString());
|
||||
formData.append('destination', destination);
|
||||
if (overwrite) {
|
||||
formData.append('overwrite', 'true');
|
||||
}
|
||||
// Send the size that we're actually sending.
|
||||
formData.append('chunkSize', chunk.size.toString());
|
||||
formData.append('chunk', chunk);
|
||||
|
|
@ -1262,15 +1266,15 @@ export const useUploadFile = () => {
|
|||
const tagsSelector = <TagsSelector selectedTagNames={tagNames} onChange={(i,) => setTagNames(i)}/>;
|
||||
|
||||
return {
|
||||
destination,
|
||||
destination, setDestination,
|
||||
doClear,
|
||||
doUpload,
|
||||
files,
|
||||
progresses,
|
||||
setDestination,
|
||||
setFiles: handleFilesChange,
|
||||
tagNames,
|
||||
tagsSelector,
|
||||
overwrite, setOverwrite,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue