I have a download button in my visualforce page, on clicking which a text file(.txt format) has to be downloaded. This text file will be created dynamically with the data stored in a Text field of a custom object. Now I am struggling to achieve this simple download functionality without creating Attachments or Document Objects. Is there any possible way to download content as plain text file? Could someone please help me with this?
I have tried the below visualforce code, but it is not downloading any files.
<a href="data:text/plain;charset=utf-8;base64,{!getEncodedData}"> Download </a></apex:outputLabel>
where getEncodedData will be the text file body.
Apex code:
getEncodedData = EncodingUtil.base64Encode(Blob.valueOf(strContent));
I am trying to achieve this without creating Attachments, simply because the created file will not be reused later.