mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
feat(java-spring): restore file by url
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
# Change Log
|
||||
|
||||
- java-spring: restore by url
|
||||
- java: restore by url
|
||||
- golang: restore by url
|
||||
- csharp-mvc: restore by url
|
||||
|
||||
@ -86,6 +86,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@ -678,16 +679,25 @@ public class FileController {
|
||||
Path bumpedFile = Paths.get(bumpedVersionStringDirectory, previousBasename);
|
||||
Files.move(sourcePathFile, bumpedFile);
|
||||
|
||||
String recoveryVersionStringDirectory = historyManager.versionDir(
|
||||
historyDirectory,
|
||||
body.getVersion(),
|
||||
true
|
||||
);
|
||||
Path recoveryPathFile = Paths.get(recoveryVersionStringDirectory, previousBasename);
|
||||
String recoveryStringFile = recoveryPathFile.toString();
|
||||
FileInputStream recoveryStream = new FileInputStream(recoveryStringFile);
|
||||
storageMutator.createFile(sourcePathFile, recoveryStream);
|
||||
recoveryStream.close();
|
||||
if (body.getUrl() != null) {
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) new URL(body.getUrl())
|
||||
.openConnection();
|
||||
InputStream stream = connection.getInputStream();
|
||||
storageMutator.createFile(sourcePathFile, stream);
|
||||
stream.close();
|
||||
connection.disconnect();
|
||||
} else {
|
||||
String recoveryVersionStringDirectory = historyManager.versionDir(
|
||||
historyDirectory,
|
||||
body.getVersion(),
|
||||
true
|
||||
);
|
||||
Path recoveryPathFile = Paths.get(recoveryVersionStringDirectory, previousBasename);
|
||||
String recoveryStringFile = recoveryPathFile.toString();
|
||||
FileInputStream recoveryStream = new FileInputStream(recoveryStringFile);
|
||||
storageMutator.createFile(sourcePathFile, recoveryStream);
|
||||
recoveryStream.close();
|
||||
}
|
||||
|
||||
JSONObject responseBody = new JSONObject();
|
||||
responseBody.put("error", null);
|
||||
|
||||
@ -30,4 +30,5 @@ import lombok.Setter;
|
||||
public class Restore {
|
||||
private String fileName;
|
||||
private Integer version;
|
||||
private String url;
|
||||
}
|
||||
|
||||
@ -298,7 +298,8 @@
|
||||
const query = new URLSearchParams(window.location.search)
|
||||
const payload = {
|
||||
fileName: query.get('fileName'),
|
||||
version: event.data.version
|
||||
version: event.data.version,
|
||||
url: event.data.url
|
||||
}
|
||||
const request = new XMLHttpRequest()
|
||||
request.open('PUT', 'restore')
|
||||
|
||||
Reference in New Issue
Block a user