Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
abdelhamed
Contributor II
Contributor II

Export Attachments from Salesforce using Teland?

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

 

Labels (3)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

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:

 

0683p000009M1ig.png

View solution in original post

9 Replies
TRF
Champion II
Champion II

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.

abdelhamed
Contributor II
Contributor II
Author

Thanks @TRF

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

0683p000009MACn.png

TRF
Champion II
Champion II

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:

 

0683p000009M1ig.png

abdelhamed
Contributor II
Contributor II
Author

 Hallo @TRF,

 

thanks so much it works like magic 0683p000009MACn.png 

 

Merci de votre aide

TRF
Champion II
Champion II

That's not magic, that's Talend!
Anonymous
Not applicable

@TRF Is there a way to simply pass the file to the next component instead of writing to your local drive?

 

Ideally I'd like to be passing the created file to a Box folder, therefore using the tBoxInput component which should be accepting the output row.

 

0683p000009M7fu.png

TRF
Champion II
Champion II

@IanJones, add an output field (let say "decoded") with datatype Object for the tJavaRow component and push the result of decodeBase64 to this field.

Then, select "Upload Incoming Content" for the Upload mode.

This should work (sorry, not tried).

If this is not enough, open a new topic.

RViswanath1674546562
Contributor
Contributor

Hi @Fred Trebuchet​ 

How can I convert ContentVersion into a file in Talend? I believe the body of an attachment and Version Data of a content version are different. Please let me know if you have any workarounds?