+ Start a Discussion
PremInfoPremInfo 

Out of memory while downloading Attachment

Hi,

 

I am using Sobject in my application and using API version 24. When I try to download the attachments more than 2 MB files I am getting Java out of memory exception. I tried by changing the heap size 512 - 1024MB even then its throwing same error. I am not facing this issue while downloading files less than 1 MB.

 

Kindly let me know the maximum size of the file I can upload or download using the SObject API.

 

Also let me know is version 24 is the latest version for chatter Sobject API, if it is not provide the latest version no. and the location of the corresponding wsdl file.

 

 

Jia HuJia Hu
The maximum file size you can upload or download via the SOAP API must fit within the 50 MB limit. When a document is uploaded or downloaded via the API, it is converted to base64 and stored in VersionData. This conversion increases the document size by approximately 37%. You must account for the base64 conversion increase so your file size doesn't exceed 50 MB.

doc:
http://www.salesforce.com/us/developer/docs/api210/Content/sforce_api_objects_contentversion.htm
PremInfoPremInfo

Hi,

 

My attachment file size is less than 25MB. As per the API document 25MB + 9.25MB (37%25) is less than 50MB. Even then I am getting the out of memory Exception. 

 

[code]

String query = "SELECT Body, CommentCount, Id, InsertedById, IsDeleted, LikeCount, LinkUrl, ParentId, RelatedRecordId, Title, Type, CreatedDate, ContentData, ContentDescription, ContentFileName, ContentSize, ContentType, Visibility FROM FeedItem WHERE Type = 'ContentPost' ORDER  BY  CreatedDate  DESC";

QueryResult result = conn.connection.query(query);

boolean done = false;

while(!done){


SObject[] records = result.getRecords();
for (int i = 0; i < records.length; ++i) {
HashMap<String, String> mapResult = new HashMap<String, String>();
Iterator<XmlObject> iterator = records[i].getChildren();
while(iterator.hasNext()){
XmlObject xmlObject = iterator.next();
if(!xmlObject.getName().toString().substring(37).equals("type")){
if(xmlObject.getValue()!=null){
if(xmlObject.getName().toString().substring(37).equalsIgnoreCase("ContentData")){
mapResult.put("AttachmentPath", xmlObject.getValue().toString());
}else{
mapResult.put(xmlObject.getName().toString().substring(37), xmlObject.getValue().toString());
}
}else{
mapResult.put(xmlObject.getName().toString().substring(37), null);
}
}
}
response.add(mapResult);
}
if(result.isDone()){
done = true;
}else{
result = conn.connection.queryMore(result.getQueryLocator());
if(result == null || result.getSize() == 0){
done = true;
}
}

}

[/code]