mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-15 06:44:16 +00:00
repair get link bug (#4220)
This commit is contained in:
@@ -55,6 +55,7 @@ class FileUploader extends React.Component {
|
|||||||
this.loaded = 0;
|
this.loaded = 0;
|
||||||
this.bitrateInterval = 500; // Interval in milliseconds to calculate the bitrate
|
this.bitrateInterval = 500; // Interval in milliseconds to calculate the bitrate
|
||||||
window.onbeforeunload = this.onbeforeunload;
|
window.onbeforeunload = this.onbeforeunload;
|
||||||
|
this.isUploadLinkLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -188,14 +189,27 @@ class FileUploader extends React.Component {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setUploadFileList(this.resumable.files);
|
this.setUploadFileList(this.resumable.files);
|
||||||
this.resumableUpload(resumableFile);
|
let { repoID, path } = this.props;
|
||||||
|
seafileAPI.getUploadLink(repoID, path).then(res => {
|
||||||
|
this.resumable.opts.target = res.data + '?ret-json=1';
|
||||||
|
this.resumableUpload(resumableFile);
|
||||||
|
}).catch(error => {
|
||||||
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
|
toaster.danger(errMessage);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.setUploadFileList(this.resumable.files);
|
this.setUploadFileList(this.resumable.files);
|
||||||
if (isFile) {
|
if (!this.isUploadLinkLoaded) {
|
||||||
this.resumableUpload(resumableFile);
|
this.isUploadLinkLoaded = true;
|
||||||
} else {
|
let { repoID, path } = this.props;
|
||||||
this.resumable.upload();
|
seafileAPI.getUploadLink(repoID, path).then(res => {
|
||||||
|
this.resumable.opts.target = res.data + '?ret-json=1';
|
||||||
|
this.resumable.upload();
|
||||||
|
}).catch(error => {
|
||||||
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
|
toaster.danger(errMessage);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -384,6 +398,8 @@ class FileUploader extends React.Component {
|
|||||||
|
|
||||||
onComplete = () => {
|
onComplete = () => {
|
||||||
this.notifiedFolders = [];
|
this.notifiedFolders = [];
|
||||||
|
// reset upload link loaded
|
||||||
|
this.isUploadLinkLoaded = false;
|
||||||
this.setState({allFilesUploaded: true});
|
this.setState({allFilesUploaded: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,6 +408,8 @@ class FileUploader extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onError = (message) => {
|
onError = (message) => {
|
||||||
|
// reset upload link loaded
|
||||||
|
this.isUploadLinkLoaded = false;
|
||||||
// After the error, the user can switch windows
|
// After the error, the user can switch windows
|
||||||
Utils.registerGlobalVariable('uploader', 'totalProgress', 100);
|
Utils.registerGlobalVariable('uploader', 'totalProgress', 100);
|
||||||
}
|
}
|
||||||
@@ -445,52 +463,24 @@ class FileUploader extends React.Component {
|
|||||||
|
|
||||||
onFileUpload = () => {
|
onFileUpload = () => {
|
||||||
this.uploadInput.current.removeAttribute('webkitdirectory');
|
this.uploadInput.current.removeAttribute('webkitdirectory');
|
||||||
let repoID = this.props.repoID;
|
|
||||||
seafileAPI.getUploadLink(repoID, this.props.path).then(res => {
|
|
||||||
this.resumable.opts.target = res.data + '?ret-json=1';
|
|
||||||
if (Utils.isIEBrower()) {
|
|
||||||
this.uploadInput.current.click();
|
|
||||||
}
|
|
||||||
}).catch(error => {
|
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errMessage);
|
|
||||||
});
|
|
||||||
if (!Utils.isIEBrower()) {
|
|
||||||
this.uploadInput.current.click();
|
this.uploadInput.current.click();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onFolderUpload = () => {
|
onFolderUpload = () => {
|
||||||
this.uploadInput.current.setAttribute('webkitdirectory', 'webkitdirectory');
|
this.uploadInput.current.setAttribute('webkitdirectory', 'webkitdirectory');
|
||||||
let repoID = this.props.repoID;
|
|
||||||
seafileAPI.getUploadLink(repoID, this.props.path).then(res => {
|
|
||||||
this.resumable.opts.target = res.data + '?ret-json=1';
|
|
||||||
if (Utils.isIEBrower()) {
|
|
||||||
this.uploadInput.current.click();
|
|
||||||
}
|
|
||||||
}).catch(error => {
|
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errMessage);
|
|
||||||
});
|
|
||||||
if (!Utils.isIEBrower()) {
|
|
||||||
this.uploadInput.current.click();
|
this.uploadInput.current.click();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onDragStart = () => {
|
onDragStart = () => {
|
||||||
let repoID = this.props.repoID;
|
|
||||||
this.uploadInput.current.setAttribute('webkitdirectory', 'webkitdirectory');
|
this.uploadInput.current.setAttribute('webkitdirectory', 'webkitdirectory');
|
||||||
seafileAPI.getUploadLink(repoID, this.props.path).then(res => {
|
|
||||||
this.resumable.opts.target = res.data + '?ret-json=1';
|
|
||||||
}).catch(error => {
|
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errMessage);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onCloseUploadDialog = () => {
|
onCloseUploadDialog = () => {
|
||||||
this.loaded = 0;
|
this.loaded = 0;
|
||||||
this.resumable.files = [];
|
this.resumable.files = [];
|
||||||
|
// reset upload link loaded
|
||||||
|
this.isUploadLinkLoaded = false;
|
||||||
this.setState({isUploadProgressDialogShow: false, uploadFileList: []});
|
this.setState({isUploadProgressDialogShow: false, uploadFileList: []});
|
||||||
Utils.registerGlobalVariable('uploader', 'isUploadProgressDialogShow', false);
|
Utils.registerGlobalVariable('uploader', 'isUploadProgressDialogShow', false);
|
||||||
}
|
}
|
||||||
@@ -532,12 +522,14 @@ class FileUploader extends React.Component {
|
|||||||
totalProgress: '100',
|
totalProgress: '100',
|
||||||
uploadFileList: uploadFileList
|
uploadFileList: uploadFileList
|
||||||
});
|
});
|
||||||
|
// reset upload link loaded
|
||||||
|
this.isUploadLinkLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onUploadRetry = (resumableFile) => {
|
onUploadRetry = (resumableFile) => {
|
||||||
|
|
||||||
seafileAPI.getUploadLink(this.props.repoID, this.props.path).then(res => {
|
seafileAPI.getUploadLink(this.props.repoID, this.props.path).then(res => {
|
||||||
this.resumable.opts.target = res.data;
|
this.resumable.opts.target = res.data + '?ret-json=1';
|
||||||
|
|
||||||
let retryFileList = this.state.retryFileList.filter(item => {
|
let retryFileList = this.state.retryFileList.filter(item => {
|
||||||
return item.uniqueIdentifier !== resumableFile.uniqueIdentifier;
|
return item.uniqueIdentifier !== resumableFile.uniqueIdentifier;
|
||||||
@@ -563,7 +555,7 @@ class FileUploader extends React.Component {
|
|||||||
onUploadRetryAll = () => {
|
onUploadRetryAll = () => {
|
||||||
|
|
||||||
seafileAPI.getUploadLink(this.props.repoID, this.props.path).then(res => {
|
seafileAPI.getUploadLink(this.props.repoID, this.props.path).then(res => {
|
||||||
this.resumable.opts.target = res.data;
|
this.resumable.opts.target = res.data + '?ret-json=1';
|
||||||
this.state.retryFileList.forEach(item => {
|
this.state.retryFileList.forEach(item => {
|
||||||
item.error = false;
|
item.error = false;
|
||||||
this.retryUploadFile(item);
|
this.retryUploadFile(item);
|
||||||
|
Reference in New Issue
Block a user