---
schema_version: "1"
id: 29920ce5c84f90718c33f94e9d89c2fb996ef3793bb4ec146d3de7211890685e
title: Amazon S3 Connector 5.7 の例
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/amazon-s3-connector/5.7/amazon-s3-connector-examples.md
canonical_url: https://docs.mulesoft.com/jp/amazon-s3-connector/5.7/amazon-s3-connector-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 4afa98692ff4cd68ef03325836660fbecbdd3f2b3153168d161461fa25f939f6
description: MuleSoft Documentation Site
release: "5.7"
latest: false
---
# Amazon S3 Connector 5.7 の例

次の例は、URL から Amazon S3 に画像を保存し、画像を取得して表示する方法を示しています。

## [](#始める前に)始める前に

Anypoint Studio でこのサンプルが機能するように、Amazon Web Services ログイン情報を提供する必要があります。次のいずれかを実行できます。

- コード内で変数を値に置き換える。
- `src/main/resources/mule-artifact.properties`​ ファイルで各変数の値を指定する。

## [](#store-and-retrieve)手順の例

![Studio 7 Visual Studio アイコンフロー。フローには、\[Listener\]、\[Create bucket (バケットを作成)\]、\[Get MuleSoft logo (MuleSoft ロゴを取得)\]、\[Create logo object in S3 bucket (ロゴオブジェクトを S3 バケットに作成)\]、\[Get Image (画像を取得)\]、\[Delete S3 bucket (S3 バケットを削除)\] が表示されています。](_images/amazon-s3-02.png)

1. Studio で新しい Mule プロジェクトを作成します。
2. **\[HTTP\] > \[Listener\]**​ をキャンバスにドラッグし、それを選択してプロパティエディターを開きます。
3. 新しい HTTP リスナー設定グローバル要素を追加します。
    
    1. \[General Settings (一般設定)\] で、​**\[+\]**​ ボタンをクリックします。
    2. 次の HTTP パラメーターを設定します。その他の項目はデフォルト値のままにし、​**\[OK\]**​ をクリックします。
        
        <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">値</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Name (名前)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">HTTP_Listener_Configuration</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Host (ホスト)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">127.0.0.1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Port (ポート)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">8081</p></td>
</tr>
</tbody>
</table>
    3. HTTP リスナーの設定グローバル要素を参照します。\[General (一般)\] タブで、​`/`​ パスを指定します。
4. Amazon S3 Connector をフローにドラッグし、コネクタをダブルクリックしてそのプロパティエディターを開きます。
5. 選択する既存の Amazon S3 Connector グローバル要素がない場合、​**\[Extension Configuration (拡張機能設定)\]**​ 項目の横にある ​**\[+\]**​ 記号をクリックします。
6. グローバル要素のプロパティを設定し、​**\[OK\]**​ をクリックします。
7. コネクタのパラメーターを設定します。
    
    ![コネクタプロパティ - \[General (一般)\] タブ](_images/amazon-s3-03.png)
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">値</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Display Name (表示名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">コネクタインスタンスの名前 (​<code>Create bucket</code>​ など)。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Extension Configuration (拡張機能設定)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">コネクタのグローバル設定。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bucket Name (バケット名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>${config.bucket}</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">リージョン</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">US_STANDARD​ (デフォルト) などのリージョン。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Canned ACL (既定 ACL)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">PRIVATE (デフォルト) アクセス制御リスト。既定 ACL は定義済みの許可です。</p></td>
</tr>
</tbody>
</table>
8. MuleSoft に MuleSoft ロゴを要求する \[HTTP\] > \[Connector (コネクタ)\] を追加します。
    
    ![「HTTP」 > 「Connector (コネクタ)」 - 「General (一般)」 タブ](/mulesoft/current/ja-jp/amazon-s3-connector/5.7/_images/amazon-s3-04.png)
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">値</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Display Name (表示名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">コネクタインスタンスの名前。この例では、[HTTP] &gt; [Connector (コネクタ)] の名前は「​<code>Get MuleSoft logo</code>​」となっています。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Configuration (設定)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>[Host (ホスト)]</strong>​ が「​<code>developer.mulesoft.com</code>​」、​<strong>[Protocol (プロトコル)]</strong>​ が「​<code>HTTPS</code>​」、​<strong>[Port (ポート)]</strong>​ が「​<code>80</code>​」の設定。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">[URL or Path (URL またはパス)]</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>/sites/all/themes/muletheme/images/mulesoft_dev_logo_v2.svg</code>​。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Body (本文)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>#[payload]</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Target Value (対象値)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>#[payload]</code></p></td>
</tr>
</tbody>
</table>
9. 要求された MuleSoft ロゴを選択された Amazon S3 バケットに作成する別の Amazon S3 Connector をドラッグします。
    
    ![S3 Connector 「Create Logo Object in S3 Bucket (ロゴオブジェクトを S3 バケットに作成)」の \[General (一般)\] タブ](_images/amazon-s3-05.png)
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">値</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Display Name (表示名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">任意の名前。この例では、S3 Connector の名前は「​<code>Create logo object in S3 bucket</code>​」となっています。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Extension Configuration (拡張機能設定)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">作成したグローバル設定。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bucket Name (バケット名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>${config.bucket}</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Key (キー)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">muledevlogo</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Content (コンテンツ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>#[payload]</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Canned ACL (既定 ACL)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">PRIVATE (デフォルト)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Storage Class (ストレージクラス)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">STANDARD (デフォルト)</p></td>
</tr>
</tbody>
</table>
10. 新規作成された MuleSoft ロゴ画像オブジェクトをバケットから取得する別の Amazon S3 Connector を追加します。
    
    ![S3 Connector 「Get Image (画像を取得)」の \[General (一般)\] タブ](_images/amazon-s3-06.png)
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">値</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Display Name (表示名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">コネクタインスタンスの名前。この例では、S3 Connector の名前は ​<code>Get Image</code>​ となっています。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Extension Configuration (拡張機能設定)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">作成するグローバル設定。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bucket Name (バケット名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>${config.bucket}</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Key (キー)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">muledevlogo</p></td>
</tr>
</tbody>
</table>
11. バケットを削除する別の Amazon S3 Connector を追加します。delete bucket 操作の戻り値のデータ型は void であるため、ペイロードには ​`get image`​ 操作で返されるオブジェクトが含まれます。
    
    ![S3 Connector 「Delete S3 Bucket (S3 バケットを削除)」の \[General (一般)\] タブ](_images/amazon-s3-07.png)
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">値</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Bucket Name (バケット名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>${config.bucket}</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Force (強制)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">True</p></td>
</tr>
</tbody>
</table>

## [](#例の-xml)例の XML

この例のフローをすばやく Mule アプリケーションに読み込むには、次のコードを Studio XML エディターに貼り付けます。

```xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:s3="http://www.mulesoft.org/schema/mule/s3"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/s3
http://www.mulesoft.org/schema/mule/s3/current/mule-s3.xsd">
  <configuration-properties file="mule-artifact.properties"/>
  <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="DOC_ID">
    <http:listener-connection host="127.0.0.1" port="8081"/>
  </http:listener-config>
  <s3:config name="Amazon_S3_Configuration" doc:name="Amazon S3 Configuration" doc:id="DOC_ID">
    <s3:basic-connection accessKey="${config.accessKey}" secretKey="${config.secretKey"/>
  </s3:config>
  <http:request-config name="HTTPS_Request_Configuration" doc:name="HTTP Request configuration" doc:id="DOC_ID">
    <http:request-connection protocol="HTTPS" host="www.mulesoft.com"/>
  </http:request-config>
  <flow name="s3docuFlow" doc:id="DOC_ID">
    <http:listener config-ref="HTTP_Listener_config" path="/" doc:name="Listener" doc:id="DOC_ID"/>
    <s3:create-bucket config-ref="Amazon_S3_Configuration" bucketName="${config.bucket}"
    doc:name="Create bucket" doc:id="DOC_ID"/>
    <http:request method="GET" path="/sites/default/files/new-application_network_diagram-01.svg"
    doc:name="Request" doc:id="DOC_ID" config-ref="HTTPS_Request_Configuration"/>
    <s3:create-object config-ref="Amazon_S3_Configuration" bucketName="${config.bucket}" key="muledevlogo"
    doc:name="Create object" doc:id="DOC_ID"/>
    <s3:get-object config-ref="Amazon_S3_Configuration" bucketName="${config.bucket}" key="muledevlogo"
    doc:name="Get object" doc:id="DOC_ID"/>
    <s3:delete-bucket config-ref="Amazon_S3_Configuration" bucketName="${config.bucket}"
    doc:name="Delete bucket" doc:id="DOC_ID" force="true"/>
  </flow>
</mule>
```

## [](#関連情報)関連情報

- [MuleSoft ヘルプセンター](https://help.mulesoft.com)
- [Amazon の「Default Provider Credential Chain (デフォルトのプロバイダーログイン情報チェーン)」](http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#using-the-default-credential-provider-chain)
- [Amazon の「アクセス制御リスト (ACL) の概要」](http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html)