Exporting attachments from Salesforce

Hello folks,
Currently using 4.2 sp07 on the DS side. We upload a csv, txt, pdf to Salesforce automatically via a third party process to Salesforce on a daily basis. Over the course of time it has turned into 1000’s attachments. Now the management wants to remove them from salesforce and store on a local drive as an individual file separated by its “order owner”. All the uploads are in the Attachment object and the Data type for Body is base64 in Salesforce.

When i try as a straight download, i get Datatype mismatch or as a gibberish file with a same data field.
Any advice on how to export those attachments and save as an individual file. So a order.pdf ends on the local drive as order.pdf and can be viewed as a pdf. Not sure if that is even possible via DS.


BOB_US (BOB member since 2006-03-16)

Salesforce stores and sends attachments in Base64, so you will need some method to decode that to get to what you want. There are many different options for this, but none directly supplied by Data Services as this is not related to it’s primary function (ETL). If you want to keep everything in DS you could write a custom transform using the Python base64 libraries.

Alternatively you could create the file and call a command line utility to convert it (ala https://www.fourmilab.ch/webtools/base64/).

Depending on your database, there may be built in functions there to help you (like http://stackoverflow.com/questions/3804279/base64-encoding-and-decoding-in-oracle).

  • E

eepjr24 :us: (BOB member since 2005-09-16)