2022-03-06 01:41:32 +01:00
|
|
|
# Multipart + AWS S3
|
|
|
|
|
2022-08-01 04:19:39 +02:00
|
|
|
Upload a file in multipart form to AWS S3 using [AWS S3 SDK](https://crates.io/crates/aws-sdk-s3).
|
2022-03-06 01:41:32 +01:00
|
|
|
|
|
|
|
# Usage
|
2020-02-06 02:51:22 +01:00
|
|
|
|
2022-08-01 02:17:59 +02:00
|
|
|
```sh
|
2021-10-06 23:28:53 +02:00
|
|
|
cd forms/multipart-s3
|
2020-02-06 02:51:22 +01:00
|
|
|
```
|
|
|
|
|
2022-08-01 04:19:39 +02:00
|
|
|
1. copy `.env.example` to `.env`
|
|
|
|
1. edit `.env` key `AWS_REGION` = your_bucket_region
|
|
|
|
1. edit `.env` key `AWS_ACCESS_KEY_ID` = your_key_id
|
|
|
|
1. edit `.env` key `AWS_SECRET_ACCESS_KEY` = your_key_secret
|
|
|
|
1. edit `.env` key `AWS_S3_BUCKET_NAME` = your_bucket_name
|
2022-03-06 01:41:32 +01:00
|
|
|
|
2022-08-01 02:17:59 +02:00
|
|
|
```sh
|
|
|
|
cargo run
|
2020-02-06 02:51:22 +01:00
|
|
|
```
|
2022-03-06 01:41:32 +01:00
|
|
|
|
2022-08-01 04:19:39 +02:00
|
|
|
Go to <http://localhost:8080> in you browser.
|
|
|
|
|
|
|
|
Or, start the upload using [HTTPie]:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
http --form POST :8080/ file@Cargo.toml
|
|
|
|
http --form POST :8080/ file@Cargo.toml file@README.md meta='{"namespace":"foo"}'
|
|
|
|
```
|
|
|
|
|
|
|
|
Or, using cURL:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
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"}'
|
|
|
|
```
|
|
|
|
|
|
|
|
[httpie]: https://httpie.org
|
|
|
|
[curl]: https://curl.haxx.se
|