Skip to Content
0

Multiple Files as Attachment

Jan 18, 2017 at 03:20 PM

118

avatar image

Hi SDNites,

I have multiple files being sent by receiver and when all the files are in the sender directory they place a trigger file and this is when I have to send all the file to the receiver. Can you please let me know how can I send multiple files as using PayloadSwapBean, I can send only 1 file at a time and not all. Please advise.

Regards,

Abhi

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Manoj K Jan 18, 2017 at 04:42 PM
0

Abhishek,

If i undersatnd correctly , for multiple files you have just one trigger file. So do you have any Filename Relation between those multiple files and Trigger fiel if yes the check below.

Sender Channel: i have just defined my main 2 Files and one common Trigger file)

in Source Folder i have total 3 files Main1, Main2 and Trigger file. Now i need to pick the Main1 and Main2 as attachment and trigger file as MainPayload.

Message Monitoring:

Br,

Manoj


snd-chnl.png (8.1 kB)
attach.png (6.7 kB)
Share
10 |10000 characters needed characters left characters exceeded
Abhishek Gupta Jan 18, 2017 at 04:50 PM
0

Thanks Manoj.

I would like to rephrase my query - I want to receive multiple files on the receiver side (Sender side I have already handled and the approach is similar to what you have told). It is a pass through scenario where 4 files being sent by sender and once the trigger file is placed, I am able to pick all the files but how do I send all these files to the receiver.

Abhi

Show 4 Share
10 |10000 characters needed characters left characters exceeded

In Receiver Channel enable "Keep attachments" (hope it is SFTP) and note you place the attachments + the trigger file . Then later if you want to delete the trigger file then run a script.

0

Hi Manoj,

Currently it is File adapter. But as mentioned above if I change it to SFTP then will be able to send the all the attachments to receiver without any issue. Please confirm.

If I am not allowed to change it to SFTP then please let me know your suggestions.

Regards,

Abhi

0

File adapter dont not support Attachments , but yes SFTP does.

Target Folder:

If SFTP is not allowed , Try Zipping all together and then send it.

Br,

Manoj

rcv-chnl.png (6.4 kB)
trg.png (10.4 kB)
0

Thanks Manoj for helpful answers.

With SFTP, I can receiver multiple attachments. But I wanted to retain the same file name as what is being used at the sender side. For which I tried to use the Advanced mode parameter and it seems to be working. The change is required at the UDF which tries to change the attachment name from attachment-1 to the actual name. But the same does not seem to be working. Can you please share your comments.

String attachmentID = null;

GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
OutputAttachments outputAttachments = globalContainer.getOutputAttachments();
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
try
{
if(inputAttachments.areAttachmentsAvailable())
{
Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);
Object[] arrayObj = CollectionIDs.toArray();
for(int i =0;i<arrayObj.length;i++)
{
attachmentID =(String)arrayObj[i];
Attachment attachment = inputAttachments.getAttachment(attachmentID);
byte[] attachmentBytes = attachment.getContent();
Attachment renameAttachment = outputAttachments.create(attachmentID, attachmentBytes);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
conf.put(key, attachmentID);
}
}
}

catch (Exception e)
{

}

return attachmentID;

SXMB_MONI screenshot

Receiver channel adapter engine monitoring (Also why the name is coming here correct but not in SXMB_MONI?)

Regards,

Abhi

n4rhq.png (9.4 kB)
oqprv.jpeg (8.1 kB)
0
Abhishek Gupta Feb 01, 2017 at 10:52 AM
0

Any comment on the above will be appreciated.

Share
10 |10000 characters needed characters left characters exceeded