In this post I will talk about sending a file to a temporary blob storage. A little warning before I get into it.
This is using the Microsoft’s blob storage that is provisioned for us. I haven’t given it a lot of thought on how it would behave in production. Take it at your own risk.
Lets start by looking back on a couple of posts last month on printing a report to a byte array.
http://dynamicsnavax.blogspot.com/2018/09/print-report-as-byte-array-via-x-in.html
http://dynamicsnavax.blogspot.com/2018/09/alternate-way-to-print-report-as-byte.html
You can use those sample pieces of code to get a report as a stream and send it to the below code.
if (stream)
{
str fileName = 'myfile';
str contentType = 'application/pdf';
str fileExtension = SRSPrintDestinationSettings::findFileNameType(SRSReportFileFormat::PDF, SRSImageFileFormat::BMP);
FileUploadTemporaryStorageStrategy fileUploadStrategy = new FileUploadTemporaryStorageStrategy();
FileUploadTemporaryStorageResult fileUploadResult = fileUploadStrategy.uploadFile(stream, fileName + fileExtension, contentType , fileExtension);
if (fileUploadResult == null || !fileUploadResult.getUploadStatus())
{
warning("@ApplicationPlatform:FileUploadFailed");
}
else
{
downloadUrl = fileUploadResult.getDownloadUrl();
if (downloadUrl == "")
{
throw Exception::Error;
}
}
}
A download URL will be generated for you. The URL is going to be public and with an expiration (15 minutes I believe).
Below is an error if you try to access it after the expiration period.