Feature

Amazon S3 API Service Plugin

Marketplace Product

The future of data exchange is here, and it’s within your reach. Experience the synergy of Amazon’s industry-leading storage and Backendless’ unmatched capabilities with the new Amazon S3 API Service Plugin. Empower your applications and streamline your data management like never before.

The plugin is available in the Backendless Marketplace and provides a comprehensive set of methods that allow seamless management of data stored in Amazon directly from within Backendless.

Amazon S3 API Service Plugin

Upload files from Backendless directly to Amazon’s cloud storage effortlessly, and seamlessly save data from Amazon to Backendless. With this plugin, managing files and folders in Amazon has never been smoother – effortlessly copy, delete, and even move files between directories A and B, all with unmatched ease.

Table of Contents

Installation Instructions

Creating the User

1. Register an account with the Amazon AWS S3.

2. Get your Access Key ID and Secret Access Key by creating a new User in the IAM Management Console.

Navigate to the Dashboard menu on the left. In the Access management section, click the Users link.

Access management select Users in Amazon AWS S3

Click the Add Users button in the IAM Console.

Click the “Add Users” button in the IAM Console

Select the appropriate username and click the Next button.

Select the appropriate username and click the “Next” button

You may now customize User Permissions to suit your requirements. If you are uncertain about the permissions you need to set, you can easily adjust them later.

For more information about Amazon User Permissions, refer to the Managing user permissions with permission groups guide.

Click the Next button to proceed.

Click Next button in Amazon User Permissions

Review all details and click the Create user button.

Review all details and click the “Create user” button

In the IAM Management Console, select the newly created user from the list of users.

In the IAM Management Console, select the newly created user from the list of users

Select the Security Credentials tab and then, in the Access keys section, click the Create access key button.

Select the “Security Credentials” tab and then in the “Access keys” section, click the “Create access key” button

Select the appropriate use case, confirm your action by checking the confirmation box, and click the Next button.

Select the appropriate use case, confirm your action by checking the confirmation box, and click the “Next” button

Create an appropriate description tag if necessary (optional) and proceed by clicking the Create access key button.

Create an appropriate description tag and proceed by clicking the “Create access key” button

Save your Access Key and Secret Access Key by clicking the Download .csv file button (recommended), or you can simply copy them to your clipboard and save where you need.

These keys are required for AWS S3 plugin installation on the Backendless side.

Save your Access Key and the Secret Access Key by clicking the “Download .csv file” button

3. Now you need to create a new bucket and configure permissions correctly.

Navigate to the S3 Management Console and click the Create bucket button.

Navigate to the S3 Management Console and click the “Create bucket” button

Creating and Configuring the Bucket

Specify the new name for your bucket and select the appropriate AWS region.

Specify the new name for your bucket and select the appropriate AWS region

In the Object Ownership section, select the ACLs Enabled and the Object writer options.

These settings will allow you to control access to each object saved in the bucket individually.

For more information about Object Ownership, refer to the “Controlling ownership of objects and disabling ACLs for your bucket” guide.

In the Object Ownership section select the “ACLs Enabled” and the “Object writer” options

Select the appropriate Public Access settings for your bucket and confirm your choice by clicking the acknowledgement checkbox.

If you want to learn more about Public Access configuration, refer to the “Configuring block public access settings for your S3 buckets” guide.

Select the appropriate Public Access settings for your bucket and confirm your choice

If necessary, configure the Bucket Versioning and set the appropriate Tags for your bucket.

If necessary, configure the Bucket Versioning and set the appropriate Tags for your bucket

Select the desired encryption type for your bucket. Otherwise, you can simply use the default settings.

At this point, the configuration of the bucket is complete, and now you can click the Create bucket button.

Select the desired encryption type for your bucket

4. Now you need to configure the Bucket Policy and the Cross-Origin Resource Sharing(CORS).

Select the newly created bucket from the list.

Select the newly created bucket from the list

Select the Permissions tab and in the Bucket policy section click the Edit button.

Select the Permissions tab and in the Bucket policy section click the “Edit” button

At this stage, you need to generate a new policy for your bucket. Copy your unique Bucket ARN value, as it is required in the next step.

Then click the Policy Generator button in the menu – you will be redirected to the policy generator page.

Click the “Policy Generator” button in the menu

In the Policy Generator, make sure to set all values as following:

  1. Select Type of Policy: S3 Bucket Policy
  2. Effect: Allow
  3. Principal: Must be set to * – the asterisk sign.
  4. Actions: Select the “All Actions” checkbox.
  5. Amazon Resource Name ( ARN ): Paste the ARN from the clipboard, which was copied in the previous step. Next, you need to add two symbols: /* – the slash and the asterisk – to the end of the ARN value. This is very important, since it instructs Amazon to provide access to all files and folders in the bucket for an external caller. Sample value: arn:aws:s3:::cats-backendless/*

Once all fields are configured, click the Add Statement button.

Once all fields are configured, click the “Add Statement” button

Review the policy and click the Generate Policy button to generate the JSON object containing the policy details.

Review the policy and click the “Generate Policy” button

In the pop-up window, copy the newly generated policy to the clipboard, close the Policy Generator tab and return back to the Bucket policy tab.

Note, that the /* symbols must be appended to the end of the ARN value in the JSON object.

In the pop-up window, copy the newly generated policy to the clipboard

Insert the policy into the corresponding text field, and click the Save changes button. You will be redirected back to the bucket configuration settings, specifically to the Permissions tab.

Insert the policy into the corresponding text field, and click the “Save changes” button

In the Permissions tab of the selected bucket, scroll down to the Cross-origin source sharing (CORS) section and click the Edit button.

In the Permissions tab of the selected bucket, scroll down to the Cross-origin source sharing (CORS) section and click the “Edit” button

Insert the following configuration and click the Save changes button:

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "GET",
            "POST",
            "DELETE"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]

This configuration allows remote callers to perform basic CRUD (Create Read Update Delete) operations in the bucket.

For more information about the CORS refer to the Using cross-origin resource sharing (CORS) guide.

Edit cross-origin resource sharing (CORS)

At this point, the bucket is ready for use. Now we have to install the Backendless AWS S3 plugin to manage this bucket from within Backendless.

Installing the AWS S3 Plugin

1. Log in to Backendless Console and select your app. Open the Marketplace screen, select the API Services section and install the AWS S3 plugin from the Backendless Marketplace.

2. During the installation, you are prompted to enter your Amazon Access Key ID, Secret Access Key, Bucket name, and server Region. The Bucket name only requires the name of the bucket and not the ARN resource name.

Keys can be obtained from Step 1 (Creating the User) of this guide, while the bucket name can be obtained from Step 2 (Creating and Configuring the Bucket) of this guide.

Enter all the details and click the Save button:

Enter Amazon keys and details in Backendless Console

2. To verify the installation, click the Cloud Code icon in Backendless Console and confirm that the AWS S3 API service appears in the list of services.

Confirm successful installation in Backendless Cloud Code

3. (When building with code) Select your language of choice to download the client SDK generated specifically for the AWS S3 service. This SDK is designed to simplify integration for developers who build their client apps with code. If the language you would like to use does not show up in the list, you can still use the plugin via REST API.

Note that you do not need an SDK to access the API via Codeless.

Download client SDK for AWS S3 service

4. If you want to provide new AWS Access and Secret keys in the future, click the gear icon. Then in the menu, enter the new details and click the Save button.

Click gear to provide new Access and Secret keys if necessary

At this stage, all the requirements are met to make API calls to the AWS S3 bucket that was set up previously. In the next section you will find the exhaustive information on the available methods that can be used to manage your bucket.

API Service Methods

copyFile

Copies the file from one directory to another in the AWS S3 bucket.

Method:

POST

Endpoint URL:

The xxxx.backendless.app is a subdomain assigned to your application. For more information, see the Client-side Setup section of the Backendless documentation.

https://xxxxx.backendless.app/api/services/AWSS3/copyFile

Request Headers:

Content-Type:application/json

Request Body: 

{
     "copySource": "value",
     "targetPath": "value"
}

Request Body Parameters:

copySource – Must be a string value. Identifies the path to the file stored in the Amazon S3 bucket. This file is copied to another directory. The format of the path to the file must be "folderName/fileName".

targetPath – Must be a string value representing the path to the folder where the file will be copied. If the target folder does not exist, a new one will be created. The format must be: 'folderName/subfolderName'.

Response Body:

{
    "CopyObjectResult": {
        "LastModified": 1690538662000,
        "ETag": "\"eff6dabc93f2f2d3b5ab7bbfb5fe5943\""
    },
    "ServerSideEncryption": "AES256"
}

Response Body Parameters:

  • LastModified – Represents the time in Unix format when the last operation took place.
  • ETag – Unique identifier assigned to each object stored in a bucket.
  • ServerSideEncryption – Provides the information about the encryption algorithm used on the server side.

Codeless reference:

The Codeless logic below copies the file “cat1.jpg” stored in the “wildCats” folder to the “testFolder/myCats” folder in the Amazon S3 bucket.

copyFile Amazon AWS S3 API service method

deleteDirectory

Deletes the specified directory from the bucket.

Method:

POST

Endpoint URL:

The xxxx.backendless.app is a subdomain assigned to your application. For more information, see the Client-side Setup section of the Backendless documentation.

https://xxxxx.backendless.app/api/services/AWSS3/deleteDirectory

Request Headers:

Content-Type:application/json

Request Body: 

{
     "directory": "value",
}

Request Body Parameters:

directory – Must be a string value. Specify the directory name to delete it from the Amazon S3 bucket. All contents stored in the directory will be also deleted. The format must be: "folderName/subfolderName".

Response Body:

None.

Response Body Parameters:

None.

Codeless reference:

The Codeless logic below deletes the “wildCats” folder with all contents from the bucket.

deleteDirectory Amazon AWS S3 API service method

uploadFile

Uploads the file stored either in Backendless Cloud or other web storage to the AWS S3 bucket. You must provide the URL of the file in the method invocation.

Method:

POST

Endpoint URL:

The xxxx.backendless.app is a subdomain assigned to your application. For more information, see the Client-side Setup section of the Backendless documentation.

https://xxxxx.backendless.app/api/services/AWSS3/uploadFile

Request Headers:

Content-Type:application/json

Request Body: 

{
     "sourcePath": "value",
     "targetPath": "value",
     "targetFileName": "value"
}

Request Body Parameters:

sourcePath – Must be a string value. Identifies the URL of the file stored either in the Backendless Cloud or in other web storage.

targetPath – Must be a string value specifying the folder name where the file will be uploaded. If the target folder does not exist, a new one will be created. The format must be: 'folderName/subfolderName'.

targetFileName – Optional parameter. Must be a string value representing a custom name for the file to be uploaded to the bucket. If you don’t specify the name of the file, Amazon will generate a random alphanumeric value to be used as the name for the uploaded file.

Response Body:

{
    "ETag": "\"eff6dabc93f2f2d3b5ab7bbfb5fed597\"",
    "Bucket": "cats-backendless",
    "ServerSideEncryption": "AES256",
    "Key": "animals/cats//cat1.jpg",
    "Location": "https://cats-backendless.s3.amazonaws.com/animals/cats//cat1.jpg"
}

Response Body Parameters:

  • ETag – Unique identifier assigned to each object stored in a bucket.
  • Bucket – The name of the Amazon S3 storage where files are stored.
  • ServerSideEncryption – Provides the information about the encryption algorithm used on the server side.
  • Key – Identifies the full path to the file, which also includes the file name.
  • Location – Represents the URL of the file in the Amazon S3 storage. By using this URL you can download the file.

Codeless reference:

The Codeless logic below uploads the file  “cat1.jpg” to the “animals/cats” folder located in the Amazon S3 bucket.

uploadFile Amazon AWS S3 API service method

deleteFile

Deletes the specified file from the bucket.

Method:

POST

Endpoint URL:

The xxxx.backendless.app is a subdomain assigned to your application. For more information, see the Client-side Setup section of the Backendless documentation.

https://xxxxx.backendless.app/api/services/AWSS3/deleteFile

Request Headers:

Content-Type:application/json

Request Body: 

{
     "filePath": "value",
}

Request Body Parameters:

filePath – Must be a string value. Identifies the full path to the file stored in the Amazon S3 bucket. The format must be: "folderName/subfolderName"

Response Body:

None.

Response Body Parameters:

None.

Codeless reference:

The Codeless logic below deletes the “cat1.jpg” file, stored in the “animals/cats” folder, from the Amazon S3 bucket.

deleteFile Amazon AWS S3 API service method

saveFile

Retrieves the file from the AWS S3 bucket and saves it to the Backendless Cloud.

Method:

GET

Endpoint URL:

The xxxx.backendless.app is a subdomain assigned to your application. For more information, see the Client-side Setup section of the Backendless documentation.

https://xxxx.backendless.app/api/services/AWSS3/saveFile

Request Headers:

Content-Type:application/json

Request Body: 

{
     "pathToSave": "value",
     "fileName": "value",
     "filePath": "value"
}

Request Body Parameters:

pathToSave – Must be a string value that identifies the path to the folder where the file will be saved in the Backendless Cloud. If the target folder does not exist, a new one will be created.

fileName – Must be a string value. Specify the name of the file that will be saved in the Backendless Cloud.

filePath – Must be a string value. Identifies the full path to the file stored in the Amazon S3 bucket. The format must be: "folderName/subfolderName/fileName".

Response Body:

The path to the folder in the Backendless Cloud where the file was saved.

Response Body Parameters:

None.

Codeless reference:

The Codeless logic below retrieves the file “cat1.jpg” from the AWS S3 bucket and saves it to the folder “animals/cats” in the Backendless Cloud. The name of the saved file is “wild_cat1.jpg” since this name was specified in the fileName parameter.

saveFile Amazon AWS S3 API service method

moveFile

Moves the specified file from the current directory in the AWS S3 bucket to another directory.

Method:

POST

Endpoint URL:

The xxxx.backendless.app is a subdomain assigned to your application. For more information, see the Client-side Setup section of the Backendless documentation.

https://xxxx.backendless.app/api/services/AWSS3/moveFile

Request Headers:

Content-Type:application/json

Request Body: 

{
     "moveSource": "string",
     "targetPath": "string"
}

Request Body Parameters:

moveSource – Must be a string value. Represents the full path to the file in the AWS S3 bucket that must be moved to another folder. The format must be: "folderName/subfolderName/fileName".

targetPath – Must be a string value. Identifies the path to the folder in the AWS S3 bucket where the file will be moved. The format must be: "folderName/subfolderName".

Response Body:

{
    "CopyObjectResult": {
        "LastModified": 1690550739000,
        "ETag": "\"eff6dabc93f2f2d3b5ab7bbfb5fe3437\""
    },
    "ServerSideEncryption": "AES256"
}

Response Body Parameters:

  • LastModified – Represents the time in Unix format when the last operation took place.
  • ETag – Unique identifier assigned to each object stored in a bucket.
  • ServerSideEncryption – Provides the information about the encryption algorithm used on the server side.

Codeless reference:

The Codeless logic below moves the file “cat1.jpg” from the “/temp” folder to the “animals/cats” folder in the AWS S3 bucket.

moveFile Amazon AWS S3 API service method

getFileURL

Retrieves the Amazon Public URL of the file stored in the AWS S3 bucket. This URL can be used to access the file directly or download it.

Method:

GET

Endpoint URL:

The xxxx.backendless.app is a subdomain assigned to your application. For more information, see the Client-side Setup section of the Backendless documentation.

https://xxxx.backendless.app/api/services/AWSS3/getFileUrl

Request Headers:

Content-Type:application/json

Request Body: 

{
     "filePath": "string"
}

Request Body Parameters:

filePath – Must be a string value. Identifies the full path to the file stored in the bucket, which is used to retrieve its Amazon Public URL. The format must be: "folderName/subfolderName/fileName". This URL can be used as the source to download the file.

Response Body:

The Public URL to the file stored in the AWS S3 bucket.

Response Body Parameters:

None.

Codeless reference:

The Codeless logic below retrieves the Amazon Public URL of the file “cat1.jpg” stored in the “animals/cats” folder.

getFileUrl Amazon AWS S3 API service method