4

Dataloader to csv doesn't work because of the binary Body, Dataloader to db seems to have problems with heap sizes and API limits ... so what works?

5 Answers 5

8

Have you taken a look at File Exporter? Here is a blog post explaining usage of it:

File Exporter

In addition, here is another way to retrieve the attachments without a third party tool.

Moving Attachments

4
  • I couldn't get File Exporter to work (with DL 22.0), but successfully downloaded the attachments using Data Export. Although this wasn't quite what I originally intended it works well. My original idea was to download the attachment body directly to the db (as a blob or similar) and whilst I managed to achieve that, I couldn't figure out how to get it to upload back as it always expected a file path as the 'body'. Sep 13, 2012 at 7:59
  • The link to File Exporter is dead. Apr 20, 2015 at 11:11
  • Update to the FileExporter Link. Please note it doesn't work with DL after 23, and 17 (download link is provided in readMe) is the suggested version per the readMe. Just used it myself and found it extremely helpful to convert the binary to the file.
    – zainogj
    Jan 30, 2016 at 18:09
  • thanks @Michael for including "Moving Attachment" blog post. #happytohelp if anyone needs more details around doing this. Jun 22, 2017 at 6:34
6

You can use the Data Loader to upload attachments to Salesforce. Before uploading attachments, note the following:

If you intend to upload via the Bulk API, verify that Upload Bulk API Batch as Zip File on the Settings | Settings page is enabled.

If you are migrating attachments from a source Salesforce organization to a target Salesforce organization, begin by requesting a data export for the source organization. On the Schedule Export page, make sure to select the Include Attachments... checkbox, which causes the file Attachment.csv to be included in your export. You can use this CSV file to upload the attachments. For more information on the export service, see Exporting Backup Data.

To upload attachments:

Confirm that the CSV file you intend to use for attachment importing contains the following required columns (each column represents a Salesforce field):

ParentId - the Salesforce ID of the parent record.

Name - the name of the attachment file, such as myattachment.jpg.

Body - the absolute path to the attachment on your local drive.

Ensure that the values in the Body column contain the full file name of the attachments as they exist on your computer. For example, if an attachment named myattachment.jpg is located on your computer at C:\Export, Body must specify C:\Export\myattachment.jpg.

Your CSV file might look like this:

ParentId,Name,Body

50030000000VDowAAG,attachment1.jpg,C:\Export\attachment1.gif

701300000000iNHAAY,attachment2.doc,C:\Export\files\attachment2.doc

The CSV file can also include other optional Attachment fields, such as Description.

Proceed with an insert or upsert operation; see Inserting, Updating, or Deleting Data Using the Data Loader. At the Select data objects step, make sure to select the Show all Salesforce objects checkbox and the Attachment object name in the list.

1

You can do this by using the Satrang Mass File Download AppExchange App and Dataloader, Using Satrang Mass File Download you can export all files and attachments along with CSV files and import these files with ParentIds in the new org.

URL - https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EcsAOUAZ&tab=e

Disclaimer: I work at Satrang Technologies, the publisher of this Mass File Download AppExchange App."

0

I would only add the following that the import wants the actual filename in the BODY field. When I downloaded the export zip files, the attachments themselves have ID names not friendly names. For example, let’s say an attachment item was named 00P3b00001XdfotEAB and it is on your hard drive in the C:\Export folder. Put that path and actual file character name in the BODY field on your CSV. It would be listed as C:\Export\00P3b00001XdfotEAB. I used the NAME field to give each attachment I uploaded a friendly name.

0

An alternative to data loader, but actually working with files is XL-Connector. It will save the files locally when doing a SOQL query, and then you can upload them from the local disk and link to respective records without having to deal with multiple CSV files and relationships, it creates all the junction records automatically: enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .