Do you want to: Report a bug
DocSpace version: 3.0.4.1
OS: Docker
Browser version: Chrome
curl -L -X PUT 'http://localhost/api/2.0/files/file/5/saveediting' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: ********' \
-d '{
"downloadUri": "https://imfile.melinked.com/2025/03/39792cb1-8437-45d4-9869-b247601d05d8.docx",
"forcesave": true
}'
I executed the command to store the file, but when I opened the file, its content had turned into the parameter I passed. It didn’t store the file correctly.
public boolean saveFile(int fileId, String token, String downloadUri) throws Exception {
String url = BASE_URL + "/api/2.0/files/file/" + fileId + "/saveediting";
CloseableHttpClient client = HttpClients.createDefault();
HttpPut httpPut = new HttpPut(url);
JSONObject jsonObject = new JSONObject();
jsonObject.put("downloadUri", downloadUri);
jsonObject.put("forcesave", true);
StringEntity entity = new StringEntity(jsonObject.toString(), "UTF-8");
entity.setContentType("application/json");
httpPut.setEntity(entity);
httpPut.setHeader("Authorization", token);
HttpResponse response = client.execute(httpPut);
String responseString = EntityUtils.toString(response.getEntity());
System.out.println(responseString);
return response.getStatusLine().getStatusCode() == 200;
}
The result of executing this Java code is also incorrect.