Skip to content

DiegoVictor/storage-gateway

Repository files navigation

Storage Gateway

serverless typescript MIT License PRs Welcome
Run in Insomnia

This project creates a Api Gateway Rest Api that serves as a proxy for S3, allowing you to download/view S3 files without the necessity of a download feature, in other words, is not necessary a Lambda to be able to download a file, the whole process will be handled by AWS infrastructure.

Infrastructure Diagram

Table of Contents

Requirements

Installing

Easy peasy lemon squeezy:

$ yarn

Or:

$ npm install

Configure

If you need change the bucket name for any reason remember to update the custom.bucketName in the serverless.ts file.

Binary Mime Types

If necessary more binary types add it in the StorageGatewayApi.Properties.BinaryMediaTypes array in the serverless.ts.

Usage

Deploy the project running the following command:

$ sls deploy --stage dev

Now run the scripts/main.js script to upload some sample files:

$ node scripts/main.js

Then get the application Rest API URL.

Routes

route HTTP Method
/images/blown.gif GET
/images/programming.jpg GET
/images/works.png GET

Below you can see the path structure:

/{folder}/{filename}
  • /images is the name of the folder where the samples were uploaded.
  • The second part (/blown.gif, /programming.jpg and /works.png) is the name of the files.

References