Save temporary upload files byte stream in memory

You should be able to handle this by using a temporary file.

Create a file with something like this on the File Upload component

fileBytes = event.file.getBytes()
extension = event.file.name.split('.')[-1] 
tempFilePath = system.file.getTempFile(extension)
system.file.writeFile(tempFilePath, fileBytes)

# Store the temporary file path in a custom property
self.view.custom.tempFilePath = tempFilePath

When you want to send the email, you can read the file back like this:

tempFilePath = self.view.custom.tempFilePath
fileBytes = system.file.readFileAsBytes(tempFilePath)
...

The uploaded files will be deleted when the gateway restarts

4 Likes