1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-21 03:18:23 +00:00

[frontend] Fix file save success issue when the file is deleted

This commit is contained in:
zhengxie
2018-07-18 14:13:44 +08:00
parent 82e130fdb9
commit 87e41d787b

View File

@@ -16,6 +16,14 @@ let dirPath = '/';
const updateUrl = `${siteRoot}api2/repos/${repoID}/update-link/?p=${dirPath}`; const updateUrl = `${siteRoot}api2/repos/${repoID}/update-link/?p=${dirPath}`;
const uploadUrl = `${siteRoot}api2/repos/${repoID}/upload-link/?p=${dirPath}&from=web`; 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) { function updateFile(uploadLink, filePath, fileName, content) {
var formData = new FormData(); var formData = new FormData();
formData.append("target_file", filePath); formData.append("target_file", filePath);
@@ -25,8 +33,7 @@ function updateFile(uploadLink, filePath, fileName, content) {
return fetch(uploadLink, { return fetch(uploadLink, {
method: "POST", method: "POST",
body: formData, body: formData,
mode: 'no-cors', }).then(handleFetchErrors);
});
} }
function getImageFileNameWithTimestamp() { function getImageFileNameWithTimestamp() {