So, basically I want to create a temporary file from a base64 string content. Right now, I'm doing this with native java-io functions. But I would like to achieve the same result using the rapture-io library for scala.
So my question would be, is it possible to achieve this with rapture-io, and if so, how?
I already went through the documentation, but is not specific enough:
https://github.com/propensive/rapture-io/blob/master/doc/introduction.md
Here's my actual code:
import org.apache.commons.codec.binary.Base64
import java.io.FileOutputStream
import java.io.File
val data: String = base64StringContent //Base64 String content of the file.
val fileName = myFileName
val fileExt = myFileExt
//It does write the file in my temp folder.
val file: File = File.createTempFile(fileName, fileExt)
val fileByteArray: Array[Byte] = Base64.decodeBase64(data)
val fileOutFile: FileOutputStream = new FileOutputStream(file)
fileOutFile.write(fileByteArray)
fileOutFile.close()
file.deleteOnExit()
file