骡子从s3桶中获取对象列表

时间:2016-06-07 06:34:24

标签: amazon-web-services amazon-s3 mule

需要通过MULE ESB从S3存储桶中检索对象列表。但是当获取payload.getkey()时,它会抛出错误:无法解析方法:org.mule.module.s3.model.ObjectListing.getKey()[arglength = 0]]

 <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="9090" doc:name="HTTP Listener Configuration"/>
<s3:config name="Amazon_S3__Configuration" accessKey="XXXXXXX" secretKey="XXXXXXXX" doc:name="Amazon S3: Configuration"/>
<flow name="s3bucket-downloadfilesFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/getfiles" doc:name="HTTP"/>
    <s3:list-objects config-ref="Amazon_S3__Configuration" bucketName="ge-datastaging-dev" prefix="Mule/inbound/" maxKeys="5" doc:name="Amazon S3"/>
    <logger level="INFO" doc:name="Logger"/>
    <foreach collection="#[payload]" doc:name="For Each">
        <logger level="INFO" doc:name="Logger" message=" inside foreach...... #[payload.getCommonPrefixes()]  ...."/>
        <logger level="INFO" doc:name="Logger" message=" ################...... #[payload.getNextMarker()]  ...."/>
        <logger level="INFO" doc:name="Logger" message=" ################...... #[payload.getKey()]  ...."/>            
    </foreach>
</flow>

1 个答案:

答案 0 :(得分:0)

不要在payload上循环,而是<foreach> ObjectSummaries对象ObjectListing上的<s3:list-objects config-ref="Amazon_S3__Configuration" bucketName="ge-datastaging-dev" prefix="Mule/inbound/" maxKeys="5" doc:name="Amazon S3"/> <foreach doc:name="For Each" collection="#[payload.objectSummaries]"> <s3:get-object-content config-ref="Amazon_S3__Configuration" bucketName="#[payload.getBucketName()]" key="#[payload.getKey()]" doc:name="Amazon S3"/> </foreach>

$.get(/some/path/here, {id: projectId, next: 4}).done(function(response)