Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
please can any one tell me how to export attachments like (xml,pdf....) from Salesfroce using Talend?
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:
@abdelhamed,check below case may be useful.
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.
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:
@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.
@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.
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?