Uploads files to an AWS S3 bucket and list them.
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [],
"MaxAgeSeconds": 3000
}
]
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
BUCKET_NAME=
GET /
: List all files in bucketGET /form
: Manually upload a file to the bucketPOST /upload
: Expects amultipart/form-data
payload to upload to S3
fetch('http://somewhere/file.jpg', { mode: 'cors' })
.then(r => r.arrayBuffer())
.then(r => {
console.log('fetched file data', r)
const formData = new FormData()
formData.append('file_input', new File([r], `test.jpg`))
fetch(
'http://uploadservice/upload',
{ method: 'POST', body: formData }
)
.then(r => r.json())
.then(console.log)
})
.catch(console.log)