Skip to content

murilopolese/uploadservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi purpose file upload service

Uploads files to an AWS S3 bucket and list them.

S3 Bucket CORS

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 3000
    }
]

Environment Variables

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
BUCKET_NAME=

Endpoints

  • GET /: List all files in bucket
  • GET /form: Manually upload a file to the bucket
  • POST /upload: Expects a multipart/form-data payload to upload to S3

Sending file programatically

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)

Reference links:

About

Multipurpuse S3 upload service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published