API to get an S3 presigned url for file uploads
Project description
cdk-s3-upload-presignedurl-api
cdk-s3-upload-presignedurl-api is AWS CDK construct library that create an API to get a presigned url to upload a file in S3.
Background
In web and mobile applications, it's common to provide the ability to upload data (documents, images, ...). Uploading files on a web server can be challenging and AWS recommends to upload files directly to S3. To do that securely, you can use pre-signed URLs. This blog post provides some more details.
Architecture
- The client makes a call to the API, specifying the "contentType" of the file to upload in request parameters (eg.
?contentType=image/png
in the URL) - API Gateway handles the request and execute the Lambda function.
- The Lambda function makes a call to the
getSignedUrl
api for aputObject
operation. - The Lambda function returns the generated URL and the key of the object in S3 to API Gateway.
- The API returns the generated URL and the key of the object in S3 to the client.
- The client can now use this URL to upload a file, directly to S3.
Getting Started
TypeScript
Installation
$ npm install --save cdk-s3-upload-presignedurl-api
Usage
import * as cdk from '@aws-cdk/core';
import { S3UploadPresignedUrlApi } from 'cdk-s3-upload-presignedurl-api';
const app = new cdk.App();
const stack = new cdk.Stack(app, '<your-stack-name>');
new S3UploadPresignedUrlApi(stack, 'S3UploadSignedUrl');
Python
Installation
$ pip install cdk-s3-upload-presignedurl-api
Usage
import aws_cdk.core as cdk
from cdk-s3-upload-presignedurl-api import S3UploadPresignedUrlApi
app = cdk.App()
stack = cdk.Stack(app, "<your-stack-name>")
S3UploadPresignedUrlApi(stack, 'S3UploadSignedUrl')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for cdk-s3-upload-presignedurl-api-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f94524fffec545dc3df87744357af0d738922965d4e0dbb9ccf36e26ce74c63 |
|
MD5 | 0a18de8b014bf6a066ae1ba43cbb9b9c |
|
BLAKE2b-256 | 2092ea85837e760e0224ee00afa5991655dab19e556c606fd253f427cabdbe50 |
Close
Hashes for cdk_s3_upload_presignedurl_api-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3ac63b92fcdae076befc3fb516b3a03b8f5fe350ad52520494cbbf68067b50c |
|
MD5 | ba86d54bca9f5ccb1d9f2c2640bf842d |
|
BLAKE2b-256 | df58c40accb776a07c9b2e835afe4edc3f574a6dc2a5518bd3d57e2343332610 |