Temporary Resource API

Last modified by Vincent Massol on 2021/04/06

A new API is available to create temporary resources. Here's an example of how you can use it:

// (1) Create the temporary resource reference.
String moduleName = "chart";
List<String> resourcePath = Arrays.asList("pie", "issuesByReporter.png");
EntityReference owningEntityReference = new DocumentReference("wiki", Arrays.asList("Path", "To"), "Page");
TemporaryResourceReference temporaryResourceReference =
   new TemporaryResourceReference(moduleName, resourcePath, owningEntityReference);

// (2) Create the temporary file.
InputStream content = new ByteArrayInputStream("content".getBytes());
File tempFile = this.temporaryResourceStore.createTemporaryFile(temporaryResourceReference, content);

// (3) Obtain the URL that can be used to access the above temporary file.
String temporaryResourceURL =
   this.urlTemporaryResourceReferenceSerializer.serialize(temporaryResourceReference).serialize();
Tags:
   

Get Connected