https://github.com/architect/macro-upload
A macro for creating an S3 bucket for processing direct uploads with a Lambda function
https://github.com/architect/macro-upload
Last synced: about 1 year ago
JSON representation
A macro for creating an S3 bucket for processing direct uploads with a Lambda function
- Host: GitHub
- URL: https://github.com/architect/macro-upload
- Owner: architect
- Created: 2019-09-28T20:12:10.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2021-09-29T16:03:54.000Z (over 4 years ago)
- Last Synced: 2025-04-03T12:02:07.086Z (about 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 5
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Security: security.js
Awesome Lists containing this project
README
# arc-macro-upload
Creates an S3 bucket for direct uploading and a Lambda function for processing direct uploads.
## Add to your project
```bash
npm i @architect/macro-upload
```
And add to your `.arc` file:
```arc
@app
testapp
@http
get /
get /success
@macros
architect/macro-upload
```
## Render the upload form
To render the upload form add the macro to any Lambdas you want to render the form. For the example `.arc` above:
```bash
cd src/http/get-index
npm i @architect/macro-upload
```
And then in the function code:
```javascript
let form = require('@architect/macro-upload/form')
exports.handler = async function http(req) {
let headers = {'content-type': 'text/html; charset=utf8'}
let redirect = `https://${req.headers.Host}/staging/success`
let body = form({redirect})
return {headers, body}
}
```
For a complete example see [arc-example-macro-upload](https://github.com/architect-examples/arc-example-macro-upload)