Export Attachments from Salesforce using Teland?

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
Forteen Stars TRF
Forteen 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
Highlighted
Thirteen Stars

Re: Export Attachments from Salesforce using Teland?

Forteen Stars TRF
Forteen 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

Forteen Stars TRF
Forteen 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

Forteen Stars TRF
Forteen Stars

Re: Export Attachments from Salesforce using Teland?

That's not magic, that's Talend!

TRF

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.