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

how to upload a file in

Hi ,


I have developed a web service using apex code and succesful to invoke it using soap Client.

Now I have one new requirement to upload a file to the custom object. how do I upload a pdf/text file to the custom object from my local file system.Is there any way to do this ? Help Appreciated.





Hi All,


I went through the link( to create a documnet.Now I got the problem in creating the Folder.


In this section Simon told like this "either query for a folderId from the Folder object, or use the UsersId, to create a document in the users private documents folder".I queried the Folders object It was returning me 0 folders.


Now my question is I can not create a folder as like this


Folder folder = new Folder();'MyUserName';(the username which i used to login)


Document doc = new Document();Blob blobObj = Blob.valueOf('This is a test String for Blob');


doc.DeveloperName ='NewAuthor';doc.ContentType=



doc.Name =eventName;



Which is giving me an Exception "System.StringException: Invalid id: 'MyUserName'.


Can any one please tell how to create the folder in Apex code.with the user specified name.


Or is it something like we need to create folders in some other palce ?






Do you really need a web service to do this?

Can't you use the <apex:inputFile> tag present in Visual Force?



You can't assign an Id for the folder. Id is unique and it is automatically created by Salesforce.