3

We are using the Box Widget in our Salesforce client and this allows our users to easily upload files to Box' system. However, we also need to upload files that may have been added by users as attachments to various objects.

Every example I've seen so far shows a Rest service sending a form POST where the intended file was received from within the browser using tags (input Type=File). However, the apex method wasn't initiated by a browser form.

Certainly we can retrieve the Attachment object, and I know how to create a Rest Service to call Box's API, but I don't know how to simulate a file upload when we only have apex Blobs to send.

2
  • 1
    What are you missing? HttpRequest.setBodyAsBlob may be a starting point?
    – jkraybill
    Apr 3, 2013 at 15:22
  • Is this still an issue for you Dave? Aug 6, 2013 at 7:07

2 Answers 2

1

Well I have worked on this while developing the BOX-APEX-SDK (API v1), Found that both the platform handles the files in different format. Salesforce generally saves the data in base64 format whereas BOX.net expects them as binary. So while uploading the file to box the file gets corrupted and if you go to box.net using browser you wont be able to view the file. Where as if you try to extract file from Box.net using api back to SF, since SF understands the base64 format and expects files to be encoded in this, SF will be able to open them without any problem.

Probably not the correct answer but hope this helps you

0

I was forwarded this link. http://enreeco.blogspot.it/2013/01/salesforce-apex-post-mutipartform-data.html It seems to answer the question perfectly, but there were errors in the final code, and when we fixed the errors as we thought they should be fixed, Box never properly handled the file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .