I am having the Base 64-encoded binary data and i want to render that as image on visualforce page. is that possible? any tips?
Thanks
|
I am having the Base 64-encoded binary data and i want to render that as image on visualforce page. is that possible? any tips? Thanks |
|||
|
|
|
What format is the image in? Assuming it's a png file you could do the following:
The tricky part though, is that you won't bre able to next an It's a little hacky, but you can assign that string to a variable:
And then assign the full string to the src property of the
This code has just been written in browser so is untested, but it should help you get to your solution. |
|||
|
|
|
This is a really interesting question which showcases some powerful (though not necessarily recommended) platform capabilities. To answer it: BlobController.cls
Blob.page
Genericizing this with a component:Potentially, this could be used (eg) to minimize HTTP requests in overhead-critical applications such as mobile clients. Without the need for a build process. This use of PageReference.getContent may be contentious, and you'd need to consume SOQL queries to properly surface the MIME types, but this works for example's sake: DataUriForResourceController.cls
dataUriForResource.component
Usage:JustInTimeCss.page
|
||||
|
|
|
See EncodingUtil for swapping between Base64 and Binary. You could probably set the entire body of the VF page to the binary/blob version and then set the ContentType of the page component to the appropriate mime-type. |
|||
|
|