function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jphalejphale 

Unable to upload a Base64 encoded image using v20+ of the API.

I can upload encoded image data using v19 of the API.  Any idea what the change is that I am missing?  I get the following error: 

 

Invalid data specified, the provided data does not seem to be a valid image: [B@574b1c

and

INVALID_DATA_URI

 

Again, if I use v20/21 I get the error, if I use v19 then all goes well and I see my image.

 

Thanks

SuperfellSuperfell

You can post an example of your request? sounds like this is an image in a rich text field ?

jphalejphale

Correct,  Within Adobe Flex, I have encoded a jpeg to Base64.  Since Rich Text Fields are not supported by the sync in the Force For Flex toolkit, I chose to upload seperately via a standard com.salesforce.connection.  I am using the following sandbox URL.

 

https://test.salesforce.com/services/Soap/u/19.0

 

if I use 20.0 or 21.0 I get the error mentioned above.  The string that I am passing to the create() in my custom object to a RichText Field looks like:

 

<img alt="Home Pict" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcU
Fh .....Many more < 32000......." />

 

Works like a charm with 19.0.

jphalejphale

Posted an update, wondered if you had any further thoughts.  Thanks

SuperfellSuperfell

I haven't been able to reproduce this yet. can you provide some more details (e.g. image size/format). If you have a standalone app that demonstrates this, that'd be great.

jphalejphale

Simon, My apologies.  I left out the critical piece of info.  I am working with the forceforflex toolkit within Adobe FlashBuilder 4.  I have been able to do quite a bit creating an offline AIR app.  Here is the declaration:

 

        <flexforforce:F3DesktopApplication id="app"
                                           statusChanged="statusChangedHandler(event)"
                                           loginComplete="_login.loginCompleteHandler(event)"
                                           loginFailed="_login.loginFailedHandler(event)"
                                           sessionExpired="_login.sessionExpiredHandler(event)"
                                           serverUrl="https://test.salesforce.com/services/Soap/u/19.0"
                                           requiredTypes="Account,Contact"/>

 

If I change the serverURL to a more recent versiojn of the API the syncing of the data fails as mentioned above. 

 

I have also tried with a driect connection rather than the built in sync:

 

 

private var sfdcWebTest:Connection;

private function login():void

{sfdcWebTest.serverUrl= "https://test.salesforce.com/services/Soap/u/19.0";
            var lr:LoginRequest = new LoginRequest();
            lr.server_url = sfdcWebTest.serverUrl;
            lr.username = _username;
            lr.password = _password;
            lr.callback = new AsyncResponder(loginComplete, messageHandler);
            sfdcWebTest.login(lr);

}

private function loginComplete ():void

{var imageSO:SObject = new SObject("Image__c");
                        imageSO.imageData__c = '<img alt="Home Pict" src="data:image/jpeg;base64,'+_encodedImagesArr[i].encodedImage+'" />';
                        imageSO.imageTypeId__c = _unsyncedImages.imageDataArr[j].imageTypeId;
                        imageSO.imageType__c = _unsyncedImages.imageDataArr[j].imageType;
                        imageSO.originalImageId__c = _encodedImagesArr[i].id;
                        aSo.push(imageSO);

sfdcWebTest.create(aSo, new AsyncResponder(imageInsertComplete, messageHandler));

}

 

 

 

When I use an API higher than 19 the create() or update() on the rich text field fail.

 

Thanks again.

Just Code ItJust Code It
Any Luck with this? I'm also having the same issue here.
Thomas LettieriThomas Lettieri
I don't know if it's related because your stuff looks much different than mine but my solution is posted here: https://developer.salesforce.com/forums/?id=906F00000008pzaIAA

The different problems I had was android was word wrapping (which the pc browser did not care about but salesforce did) and some formatting issues