1
0
mirror of https://github.com/actix/examples synced 2024-11-23 14:31:07 +01:00
examples/forms/multipart-s3
dependabot[bot] 1b43dde946
Bump the aws group with 1 update (#653)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rob Ede <robjtede@icloud.com>
2023-11-20 18:54:13 +00:00
..
src Bump the aws group with 1 update (#653) 2023-11-20 18:54:13 +00:00
.env.example return uploaded files information in s3 example 2022-08-01 03:19:39 +01:00
.gitignore Restructure folders (#411) 2021-02-26 00:57:58 +00:00
Cargo.toml Bump the aws group with 1 update (#653) 2023-11-20 18:54:13 +00:00
README.md add read and detele object endpoints to s3 example 2022-08-01 03:53:29 +01:00

Multipart + AWS S3

Upload a file in multipart form to AWS S3 using AWS S3 SDK.

Usage

cd forms/multipart-s3
  1. copy .env.example to .env
  2. edit .env key AWS_REGION = your_bucket_region
  3. edit .env key AWS_ACCESS_KEY_ID = your_key_id
  4. edit .env key AWS_SECRET_ACCESS_KEY = your_key_secret
  5. edit .env key AWS_S3_BUCKET_NAME = your_bucket_name

The AWS SDK automatically reads these environment variables to configure the S3 client.

cargo run

Go to http://localhost:8080 in you browser.

Or, start the upload using HTTPie:

http --form POST :8080/ file@Cargo.toml
http --form POST :8080/ file@Cargo.toml file@README.md meta='{"namespace":"foo"}'

http GET :8080/file/<key_from_upload>

Or, using cURL:

curl -X POST http://localhost:8080/ -F 'file=@Cargo.toml'
curl -X POST http://localhost:8080/ -F 'file=@Cargo.toml' -F 'file=@README.md' -F 'meta={"namespace":"foo"}'

curl http://localhost:8080/file/<key_from_upload>