2241

Mule ESB: How to take all the files in a folder inside Bucket of Amazon S3 ( get object content)

Question:

i'm using Amazon S3 , My bucket have mutiple files in a input folder.i need to take all files in a folder and process it, right now i can able to take one file and process it by providing the key value. But not sure how to take all the files in a bucket (input is my folder name in a bucket) at a one shot. Please find my config below

<s3:config name="Amazon_S3" accessKey="myKey" secretKey="MySecretkey" doc:name="Amazon S3"/> <flow name="s3Flow1" doc:name="s3Flow1"> <http:inbound-endpoint exchange-pattern="one-way" host="localhost" port="8081" doc:name="HTTP"/> <logger message="*********Inside yes************" level="INFO" doc:name="Logger"/> <s3:list-objects config-ref="Amazon_S3" bucketName="getfiles" doc:name="Amazon S3" maxKeys="5" delimiter="/" prefix="input/"/> <json:object-to-json-transformer doc:name="Object to JSON"/> <logger message="..InsidePay..#[payload]********" level="INFO" doc:name="Logger"/> <s3:get-object-content config-ref="Amazon_S3" bucketName="my_backetName" key="input/test.xml" doc:name="Amazon S3"/> <file:outbound-endpoint path="C:\OUT" responseTimeout="10000" doc:name="File" outputPattern="#[function:dateStamp].xml"/> </flow>

When it try to add more files name or * value in Key =input/* . It is throwing error. Please help me on resolving the issue. Thanks in advance.

Answer1:

You need to get the object content for each file. For this you could use the foreach router and use #[payload.getKey()] to get the current object's key:

<s3:list-objects config-ref="Amazon_S3" bucketName="getfiles" doc:name="Amazon S3" maxKeys="5" delimiter="/" prefix="input/"/> <foreach doc:name="For Each file"> <s3:get-object-content config-ref="Amazon_S3" bucketName="my_backetName" key="#[payload.getKey()]" doc:name="Amazon S3"/> </foreach>

Recommend

  • Spark: read csv file from s3 using scala
  • TapJoy crash iPhone app [duplicate]
  • Mapping List in YAML file to List of objects
  • How can I send a multi-part email with text/plain and text/html with Exchange Web Services?
  • C# Dataset or not? [closed]
  • QT - QFileSystemModel on server-client program
  • Content based file moving with Mule
  • Commas in python?
  • What is the proper Java Config for simple file copy
  • Different browser means a different client from the same machine
  • BPEL Designer for Eclipse: how to debug a BPEL process
  • ColdFusion with IIS URL Rewrite - Page never finishes loading
  • UIPanGestureRecognizer - move view instantly
  • Cannot create StorageItem in Outlook Add-In
  • Is there a limit to the number of exchanges for rabbitmq?
  • Task Scheduler Error Message: 80041318, Whats it mean?
  • Amazon Europe MWS Python Boto Connection AccessDenied
  • How to Correctly Run Python Script from PHP [duplicate]
  • RFX equivalent data type for _int64 in Informix
  • Camel REST Bean Chaining
  • why my app based on boost::asio didn't accept new connection
  • how to read a file in prolog?
  • Unable to connect to OnVif enabled camera using C#
  • Streaming screenshots over WebRTC as a video stream from iOS
  • Setting WPF Window Background to Resource Dictionary Brush User Setting
  • Runtime.exec() gives Error: Could not find or load main class
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • quiver not drawing arrows just lots of blue, matlab
  • Unexpected token ILLEGAL while running node.js mocha test
  • How to attach a node.js readable stream to a Sendgrid email?
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • Is there a amazon webstore API for customers?
  • JSON with duplicate key names losing information when parsed
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?