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
dke01dke01 

Posting Binary data

I want to upload a file using a pure HTML form, i.e. No Visual force but instead of gettign the file data as a Blob I just get a reference to the file as:

 

/home/sfdc/salesforce/sfdc/jsp/form/form1433903752.tmp   is there any API call we can use to convert that into an blob or attachment

 

This is my HTML

 

 <form id="myForm1" action="fileTest" method="POST" enctype="multipart/form-data">
       <input type="hidden" name="MAX_FILE_SIZE" value="100000" />

        File: <input type="file" name="file" />
   <input type="submit" value="Submit" />

  </form>

 

 

This my apex

 

 public fileTest()
    {
        Map<String, String> m = System.currentPageReference().getParameters();
        for(string key : m.keySet())
        {
              System.debug('============= key ='+ key  + ':'+     System.currentPageReference().getParameters().get(key));
            
        }
       
    }

 
I get back the file name, file content type, but not the file binary data just a internal folder/file path such as /home/sfdc/salesforce/sfdc/jsp/form/form1433903752.tmp    is there any hooks I can use to covert that into a Blob?

 

Yes I do know I can use Visualforce to do this and save directly to an Attachment or Document. But I do not want to do this.

 

gliustonecobragliustonecobra

This doesn't seem straighforward, from what I've found:

 

http://boards.developerforce.com/t5/Apex-Code-Development/Posting-in-binary-data/td-p/127004

 

http://blogs.developerforce.com/developer-relations/2011/09/using-binary-data-with-rest.html

http://boards.developerforce.com/t5/forums/forumtopicprintpage/board-id/apex/message-id/53478/print-single-message/false/page/1

 

But the blog entry does mention encoding the blob as a base64 and then passing as a param. then decoding in apex. that's the next step I'll try.

 

Let me guess....you're trying to build a multi-file uploader? :)