You need to sign in to do that
Don't have an account?
Jaggy
File upload to chatter
Hi guys,
I am using phonegap and salesforce mobile SDK. I want to post a file to chatter. But I am unable to make out. Following is my code snippet. Any kind of help will be highly appriciated.
var comment = $("#comment").val(); var params = new Object(); params.desc = "description"; params.fileName = "filename"; params.text = comment; params.feedItemFileUpload = imageData; // response from phonegap getPicture methods forcetkClient.createFeedItem(params, postSuccess, postError); forcetk.Client.prototype.createFeedItem = function(fields, callback, error) { var str = []; for(var p in fields) str.push(p + "=" + encodeURIComponent(fields[p])); str = str.join("&"); this.ajax('/' + this.apiVersion + '/chatter/feeds/news/me/feed-items' , callback, error, "POST", str); }
Thanks
I think the issue here is that you're trying to encode the file data as a query parameter in the URI itself rather than in the HTTP POST body.
I haven't tried this, but I believe there is a Chatter Connect API specifically for uploading files. Take a look at this Chatter Connect API reference page. I believe what you want to do is set fileData in the POST body.
Hope this helps...
Hi Jagdeep,
It looks like you're making use of the Chatter REST API. I have answered a similar question before here: http://boards.developerforce.com/t5/Chatter-and-Chatter-API/Chatter-REST-API-File-Upload-using-Request-body/m-p/367373#M1331 hope it helps.
Cheers,
- Chris