AWS S3

Connect with Amazon Simple Storage Service (Amazon S3) without any backend coding.

Overview

Amazon Simple Storage Service (Amazon S3) is a scalable, high-speed, web-based cloud storage service. The service is designed for online backup and archiving of data and applications on Amazon Web Services (AWS). Amazon S3 was designed with a minimal feature set and created to make web-scale computing easier for developers.

SlashApi provide a simple API endpoint to connect with your AWS S3 files using API without writing any backend code.

Getting Started

After you create an account and log in to the dashboard, choose AWS S3 on the collections page. To make AWS S3 API we need these values:

  • Access Key
  • Secret Access Key
  • Region
  • Bucket Name

Get your access key

Let's start with IAM service to get your encryption key.

  1. On AWS console page select IAM service OR Click Here
  2. On Left sidebar Select Users and on users page Click on Add user
  3. Enter User name and set access type to Programmatic access as we are going to communicate programmatically with AWS services (S3). After that click on Next Permissions
  4. On Next screen, Select Attach Existing Policy Directly. A list of Policies will appear. Search for S3 and select AmazonS3FullAccess. Then Click on Next: Tags Button.
  5. You can skip tags as these are optional. Just click on Next: Review Button
  6. On Review screen Verify all your settings and click on Create User Button.
  7. After Creating user, you can get your Access key ID and Secret Access key.

API Endpoints

List All Files

List all files in your AWS S3

GET
<team>/aws-s3/<identifier>/files

Parameters

Parameter Description
recursive Operating on a directory and its contents, including the contents of any subdirectories
directory Directory root

Example

var axios = require('axios');

var config = {
    method: 'get',
    url: 'http://v1.slashapi.com/slashapi/aws-s3/u2nyrJqa0f/files?directory=your-directory'
};

axios(config)
    .then(function (response) {
        console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
        console.log(error);
    });

List All Directories

List all directories in your AWS S3

GET
<team>/aws-s3/<identifier>/directories

Parameters

Parameter Description
recursive Operating on a directory and its contents, including the contents of any subdirectories
directory Directory root

Example

var axios = require('axios');

var config = {
    method: 'get',
    url: 'http://v1.slashapi.com/slashapi/aws-s3/u2nyrJqa0f/directories?directory=your-directory'
};

axios(config)
    .then(function (response) {
        console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
        console.log(error);
    });

Download File

Download File from your AWS S3

GET
<team>/aws-s3/<identifier>/download

Parameters

Parameter Description
path [required] Path to file

Example

var axios = require('axios');

var config = {
    method: 'get',
    url: 'http://v1.slashapi.com/slashapi/aws-s3/u2nyrJqa0f/download?path=path-to-file'
};

axios(config)
    .then(function (response) {
        console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
        console.log(error);
    });

Upload File

POST
<team>/aws-s3/<identifier>

Upload File to your AWS S3.

Request Body

Body Description
file [required] File to upload
directory Destination directory for your uploaded file

Example

var axios = require('axios');
var FormData = require('form-data');
var fs = require('fs');
var data = new FormData();
data.append('file', fs.createReadStream('/path/to/file'));
data.append('directory', 'target-directory');

var config = {
    method: 'post',
    url: 'http://v1.slashapi.com/slashapi/aws-s3/u2nyrJqa0f',
    headers: {
        ...data.getHeaders()
    },
    data : data
};

axios(config)
    .then(function (response) {
        console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
        console.log(error);
    });

Delete Files

Delete Files in your AWS S3

DELETE
<team>/aws-s3/<identifier>

Request Body

Body Description
files [required] Path to files. To delete multiple files, you can pass an array

Example

var axios = require('axios');
var data = JSON.stringify({
    "files": [
        "Directory/your-file.jpeg"
    ]
});

var config = {
    method: 'delete',
    url: 'http://v1.slashapi.com/slashapi/aws-s3/u2nyrJqa0f',
    headers: {
        'Content-Type': 'application/json'
    },
    data : data
};

axios(config)
    .then(function (response) {
        console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
        console.log(error);
    });

Delete Directory

Delete directory in your AWS S3

DELETE
<team>/aws-s3/<identifier>

Request Body

Body Description
directory [required] Target directory

Example

var axios = require('axios');
var data = JSON.stringify({
    "directory": "target-directory"
});

var config = {
    method: 'delete',
    url: 'http://v1.slashapi.com/slashapi/aws-s3/u2nyrJqa0f',
    headers: {
        'Content-Type': 'application/json'
    },
    data : data
};

axios(config)
    .then(function (response) {
        console.log(JSON.stringify(response.data));
    })
    .catch(function (error) {
        console.log(error);
    });