When uploading to zenodo upload both pdf and the RDA json files
This commit is contained in:
parent
5b930a6870
commit
c929eb3a2b
|
@ -1956,6 +1956,21 @@ public class DataManagementPlanManager {
|
|||
restTemplate.put(addFileUrl, addFileMapRequest);
|
||||
Files.deleteIfExists(file.getFile().toPath());
|
||||
|
||||
ResponseEntity<byte[]> jsonFile = getRDAJsonDocument(id.toString(), datasetManager, principal);
|
||||
UUID jsonFileUUID = UUID.randomUUID();
|
||||
File tempJsonFile = new File(this.environment.getProperty("temp.temp") + jsonFileUUID.toString() + ".json");
|
||||
try (FileOutputStream jsonFos = new FileOutputStream(tempJsonFile)) {
|
||||
jsonFos.write(jsonFile.getBody());
|
||||
jsonFos.flush();
|
||||
}
|
||||
fileSystemResource = new FileSystemResource(tempJsonFile);
|
||||
addFileMapRequest = new HttpEntity<>(fileSystemResource, null);
|
||||
String jsonFileName = jsonFile.getHeaders().get("Content-Disposition").get(0).substring(jsonFile.getHeaders().get("Content-Disposition").get(0).lastIndexOf('=') + 1);
|
||||
addFileUrl = links.get("bucket") + "/" + jsonFileName + "?access_token=" + zenodoToken;
|
||||
restTemplate.put(addFileUrl, addFileMapRequest);
|
||||
Files.deleteIfExists(tempJsonFile.toPath());
|
||||
|
||||
|
||||
// Third post call to Zenodo to publish the entry and return the DOI.
|
||||
publishUrl = links.get("publish") + "?access_token=" + zenodoToken;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue