Skip to Content

Multiple Files as Attachment

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jan 18, 2017 at 04:42 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 18, 2017 at 04:50 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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)
  • Feb 01, 2017 at 10:52 AM

    Any comment on the above will be appreciated.

    Add comment
    10|10000 characters needed characters exceeded