How to store text file in temporary blob storage for user download in ax 7

Hi All,

I am working on AX 7 .
How to store text file in temporary blob storage by code and user can download that file.

Kindly mention how to achive that by code.

Thanks
Sumit

Use File::SendFileToUser(). You might also want to look at my blog post File upload and download in AX 7.

Hi Martin

Thanks for your reply.
And it’s an excellent blog.
But Where i will apply the File::SendFileToUser() i am not pretty clear.

Can you verify the below code and If possible share some code by which i can achive the download file.

[Control(“Button”)]
class DownloadTest
{
///


///
///

public void clicked()
{
System.IO.Stream fileStream;
DocuValue docuValue;

fileStream = Binary::constructFromContainer(docuValue.File,docuValue.getMemoryStream());
File::SendFileToUser(fileStream ,docuValue.OriginalFileName);
new Browser().navigate( File::SendFileToTempStore(fileStream ,docuValue.OriginalFileName));
fileStream.close();
}
}

Thanks
Sumit

Why are you trying to put the file to the temporary storage again and navigate users to the file again? It’s all already done by SendFileToUser().

This is all code you need:

using (var stream = ...)
{
    File::SendFileToUser(stream, docuValue.OriginalFileName);
}