Skip to main content
Hi!

i am dealing this problem since some days... Anybody has make work an visual force with contenttype as image/jpeg(not in a img src tag, directly in the apex page declaration)?

When I use a base64 in a img src, it works perfectly. But if I try in a visualforce declaration, I always have a broken link.

My problem is that I am trying to have a link like xxxx.com/name=imagename

The result should be a image, not an html with a image, like when you right click on a image and you choose open image in a tab.

With the salesforce imageserver, that works perfectly, with servlet/servlet.ImageServer, i want to do the same with my visual force page, but it is..struggling :-)

this visual force is like this

<apex:page showHeader="false" sidebar="false" standardStylesheets="false" controller="pageController" contentType="image/jpeg">

{!bodyContent}

</apex:page>

and the controller just do a query on a document, encode the document body in base64, and returns it.

So if any of you have a visual force with contenttype image/jpeg which works, it would help me a lot if you share your solution

Merry Christmas everyone!
2 risposte
  1. 26 dic 2015, 04:04
    I cannot for the life of me get this to work.  All of the data that I get back when using cURL to pull down the page I get

     

    ASCII text, with very long lines, with no line terminators

    In order for the image to be properly rendered as a true jpg it'll have to be

     

    JPEG image data

    with some sort of EXIF or JFIF standard.  To do this for jpeg (or any image format) you have to convert the base64 image to a bytecode image.  I cannot find anyway to do this inside of Salesforce.  I did find the post that mentioned the code you have above but could not get it to work.  I wonder if the person who got it to work was using a specific browser that allowed it.
0/9000