mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 02:48:51 +00:00
[frontend] Fix file save success issue when the file is deleted
This commit is contained in:
@@ -16,6 +16,14 @@ let dirPath = '/';
|
||||
const updateUrl = `${siteRoot}api2/repos/${repoID}/update-link/?p=${dirPath}`;
|
||||
const uploadUrl = `${siteRoot}api2/repos/${repoID}/upload-link/?p=${dirPath}&from=web`;
|
||||
|
||||
function handleFetchErrors(response) {
|
||||
if (!response.ok) {
|
||||
// response 4xx/5xx will be caught, and rejected in the promise chain
|
||||
throw Error(response.statusText);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
function updateFile(uploadLink, filePath, fileName, content) {
|
||||
var formData = new FormData();
|
||||
formData.append("target_file", filePath);
|
||||
@@ -25,8 +33,7 @@ function updateFile(uploadLink, filePath, fileName, content) {
|
||||
return fetch(uploadLink, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
mode: 'no-cors',
|
||||
});
|
||||
}).then(handleFetchErrors);
|
||||
}
|
||||
|
||||
function getImageFileNameWithTimestamp() {
|
||||
|
Reference in New Issue
Block a user