[SalesForce] Size of an attachment

Is there any api in salesforce to find out the size of an attachment? I am creating package.XML in Salesforce and I would like to make sure that the size is less than 3 MB.

Best Answer

Is there any api in salesforce to find out the size of an attachment?

You can find attachment size with a simple SOQL query (available via SOAP API) like so:

select Id, Name from Attachment where BodyLength < 3000000

Not quite sure why you mentioned attachment size with relation to package.xml though. package.xml deals with Metadata while Attachment is Data and package.xml is not meant to deal with data.