You need to sign in to do that
Don't have an account?
Nikita Yadav 17
Convert VersionData to actual file
Hello,
Its urgent !!
I have public site where i want to give a access to user to view and download the files stored in VersionData field of ContentVersion object.
I am using aura and apex for the above requirement and I am uanble to find out the way to convert VersionData to actual file. Can anybody help me to convert VersionData to actual file using aura and apex.
Thank you.
Its urgent !!
I have public site where i want to give a access to user to view and download the files stored in VersionData field of ContentVersion object.
I am using aura and apex for the above requirement and I am uanble to find out the way to convert VersionData to actual file. Can anybody help me to convert VersionData to actual file using aura and apex.
Thank you.
You can use Apex to retrieve the binary data stored in the VersionData field of the ContentVersion object, and then convert it to an actual file that can be downloaded by the user. Here is some sample code that shows how to do this:
First, create an Apex controller that retrieves the binary data from the VersionData field and returns it as a Blob object:
Next, create an Aura component that calls the Apex controller to retrieve the file content and convert it to an actual file. Here is an example component that allows the user to download a PDF file:
Finally, create a controller for the Aura component that retrieves the file content from the Apex controller, converts it to a file, and initiates the download:
This code retrieves the binary data from the ContentVersion object using the Apex controller, creates a new Blob object, creates a link to the Blob object with a download attribute, and then clicks the link to initiate the download.
You can modify this code to support other file types by changing the filename and/or the MIME type in the Blob object.
Hope the above information is helpful !
Thank you.
This is not working.I am not getting any error but VersionData Returns value like Blob[149865].
Do i need to convert this value to blob ?