You need to sign in to do that
Don't have an account?
URGENT: Where to upload image file to force.com space at runtime
Hello,
I'm new to force.com development and running out of ideas (and time!), so help is really appreciated.
I have a mobile application from which the end user should be able to upload an image file to somewhere on my force.com platform, ideally a fileserver area (rather than in a databse) and then store the URL to the image within a filed of my custom object.
Can someone advise where I can upload the images (they will be specific to records within my custom object) I don't even know if this is possible and if so, then what objects or API I should be calling. At the moment, I was trying to use REST API via RestRequest.
Thanks
Hi,
You can insert the attachment for the particular record in your custom object. In attachment object there is a parented field in which pass the id of the record in which you want to save to image or anything.
Use the below code snippet as reference:
StaticResource ss=[Select Name, ContentType, Body From StaticResource limit 1];
Attachment Attachment1= new Attachment (Name=ss.name,contenttype=ss.contenttype,body=ss.body,IsPrivate=false,ParentId=contact.id);
insert Attachment1;
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Thanks for the quick response Ankit, althought my exposure to the API is a little limited to Java (android dev) using REST, I know how to perform a regular read or update operation as below for example:
String objectType = "Work_Request__c";
String objectId = mRecordID;
Map<String, Object> fields = new HashMap<String, Object>();
fields.put("Status__c","Complete");
RestRequest request = RestRequest.getRequestForUpdate(apiVersion, objectType, objectId, fields);
client.sendAsync(request, new AsyncRequestCallback() ...
Could I convert your snippet into a form as above or should I be looking to do something completely differed to above?