Export Attachments from Salesforce using Teland?

Highlighted
Five Stars

Export Attachments from Salesforce using Teland?

please can any one tell me how to export attachments like (xml,pdf....) from Salesfroce using Talend?

 


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: Export Attachments from Salesforce using Teland?

As a minimalist solution, connect your tSalesforceInput component to a tJavaRow with the following code:

 

if(input_row.BodyLength > 0) {
    File f = new File(context.YourOutputPath + "/" + input_row.Name);
    FileOutputStream output = new FileOutputStream(f);
    byte[] decoded = Base64.decodeBase64(input_row.Body);
    output.write(decoded);
}

Include the these lines into the advanced settings tab of the tJavaRow component:

 

 

import java.io.File;
import java.io.FileOutputStream;
import org.apache.commons.codec.binary.Base64;

The schema for the tSalesforce component should look like this:

 

Capture.png


TRF

All Replies
Thirteen Stars

Re: Export Attachments from Salesforce using Teland?

@abdelhamed,check below case may be useful.

 

https://community.talend.com/t5/Design-and-Development/resolved-Upload-Attachment-into-Salesforce/td...

Manohar B
Don't forget to give kudos/accept the solution when a replay is helpful.
Fifteen Stars TRF
Fifteen Stars

Re: Export Attachments from Salesforce using Teland?

The link provided by @manodwhb is for upload, not for download but you can found many links on Google searching for "java salesforce attachment dowload".

The principle is derived from the upload process: query the attachment objet - decode64 the body content - create the output file.

 

Hope this helps.


TRF
Five Stars

Re: Export Attachments from Salesforce using Teland?

Thanks @TRF

can you please help me more i dont know from where i can start.

Smiley Happy

Fifteen Stars TRF
Fifteen Stars

Re: Export Attachments from Salesforce using Teland?

As a minimalist solution, connect your tSalesforceInput component to a tJavaRow with the following code:

 

if(input_row.BodyLength > 0) {
    File f = new File(context.YourOutputPath + "/" + input_row.Name);
    FileOutputStream output = new FileOutputStream(f);
    byte[] decoded = Base64.decodeBase64(input_row.Body);
    output.write(decoded);
}

Include the these lines into the advanced settings tab of the tJavaRow component:

 

 

import java.io.File;
import java.io.FileOutputStream;
import org.apache.commons.codec.binary.Base64;

The schema for the tSalesforce component should look like this:

 

Capture.png


TRF
Five Stars

Re: Export Attachments from Salesforce using Teland?

 Hallo @TRF,

 

thanks so much it works like magic Smiley Happy 

 

Merci de votre aide

Fifteen Stars TRF
Fifteen Stars

Re: Export Attachments from Salesforce using Teland?

That's not magic, that's Talend!

TRF

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.