Amazon S3 Extension

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

Version: 1.1.1

Manage files in an Amazon S3 bucket. With this extension, you can list, download, and delete files. You can also generate a signed URL for downloading a file.

Each configured instance of this extension works with a specific bucket. For multiple buckets, use a configured instance of this extension for each bucket.

Prerequisites

Before using the extension from an API proxy using the ExtensionCallout policy, you must:

About Amazon S3

Amazon Simple Storage Service (Amazon S3) is an object storage service.

Actions

deleteFile

Deletes the specified file from an S3 bucket.

Syntax

<Action>deleteFile</Action>
<Input><![CDATA[
{
  "fileName" : "name-of-file-to-delete"
}
]]>
</Input>

Example

<Action>deleteFile</Action>
<Input><![CDATA[
{
  "fileName" : "names.tmp"
}
]]>
</Input>

Request parameters

Parameter Description Type Default Required
fileName The name of the file to delete. String None. Yes.

Response

None.

Response properties

None.

downloadFile

Downloads the specified file from an S3 bucket.

Syntax

<Action>downloadFile</Action>
<Input><![CDATA[
{
  "fileName" : "filename"
}
]]>
</Input>
<Output>flow-variable</Output>

Example

<Action>downloadFile</Action>
<Input><![CDATA[
{
  "fileName" : "product-sheet.pdf"
}
]]>
</Input>
<Output>downloaded.file</Output>

Request parameters

Parameter Description Type Default Required
fileName The name of the file to download. String None. Yes.

Response

JSON with a content property containing the file's content.

{
  "content":"Hello World!"
}

Response properties

Property Description Type Default
content A string containing the requested file's content. String. None.

generateSignedURL

Generates a signed URL for downloading the specified file from an S3 bucket.

Syntax

<Action>generateSignedURL</Action>
<Input><![CDATA[
{
  "fileName": "filename",
  "expiresIn": duration-in-seconds
}
]]>
</Input>
<Output>flow-variable</Output>

Example

<Action>generateSignedURL</Action>
<Input><![CDATA[
{
  "fileName": "product-info.pdf",
  "expiresIn": 3600
}
]]>
</Input>
<Output>download.url</Output>

Request parameters

Parameter Description Type Default Required
fileName The name of the file to download. String None. Yes.
expiresIn The duration in seconds until the URL expires. Integer 86400 No.

Response

JSON with a url string property containing the generated URL.

{
  "url":"https://fake.s3.amazonaws.com/hello_world.txt?AWSAccessKeyId=123&Expires=1542753572&Signature=ABC"
}

Response properties

Property Description Type Default
url A URL to the requested file. String None.

listFiles

Invokes the execution of an AWS Lambda function.

Syntax

<Action>listFiles</Action>
<Input><![CDATA[{}]]></Input>
<Output>flow-variable</Output>

You must specify parsed="false" on the <Output> element if you would like the variable to contain the raw JSON. Otherwise, the variable is not usable.

Example

<Action>listFiles</Action>
<Input><![CDATA[{}]]></Input>
<Output parsed="false">listFilesOutput</Output>

Request parameters

None.

Response

An array of S3 file names.

["hello_world.txt"]

Response properties

None.

Configuration Reference

Use the following when you're configuring and deploying this extension for use in API proxies. For steps to configure an extension using the Apigee console, see Adding and configuring an extension.

Common extension properties

The following properties are present for every extension.

Property Description Default Required
name Name you're giving this configuration of the extension. None Yes
packageName Name of the extension package as given by Apigee Edge. None Yes
version Version number for the extension package from which you're configuring an extension. None Yes
configuration Configuration value specific to the extension you're adding. See Properties for this extension package None Yes

Properties for this extension package

Specify values for the following configuration properties specific to this extension.

Property Description Default Required
configuration Enter the name of the Amazon S3 bucket to use, such as sample-bucket. None. Yes.
configuration Enter the name of the AWS region to use, such as us-east-2. None. Yes.
credentials When entered in the Apigee Edge console, this is a JSON file containing your Amazon access key ID and access key in the following form:

{
"accessKeyId" : access-key-ID,
"secretAccessKey" : secret-access-key
}

When sent via the management API, it is a base64-encoded value generated from that key JSON file.
None. Yes.