Background: user need to mass upload files as attachment in Account or Opportunity.
Solution: Using Data Loader to mass upload files to attachment. If you need to regularly do mass upload, you can schedule Data Loader, see this user guide.
1. Prepare CSV file
You can use Ms Excel to create new CSV file with following columns:
- ParentId - Id of the record to which the attachment should be associated
- Name - Name of the attachment (you can put file name here)
- ContentType - Format of the extension (e.g. image/jpeg, application/vnd.ms-excel, etc), if you not sure, you can run SOQL query to Attachment object for similar file type. However, this field is not mandatory, so you can leave it blank or un-map it.
- OwnerId - Id for the owner of the attachment (UserId). If you not put any UserId here, your UserId will be OwnerId
- Body - File path to the attachment on the local machine (C:\temp\how to make gold.png)
2. Login to Apex Data Loader
- Select the "Insert" button.
- In the 'Select Salesforce Object' window, select the 'Show all Salesforce Objects' checkbox and then select "Attachment".
- Choose the CSV file you have prepare above.
- In the mapping step, map the following fields:
Click "OK" to proceed with the insert. It may take a few minutes depends on the number of file and file size, but the attachments should be successfully uploaded to your Salesforce.
Hope this help.