GithubHelp home page GithubHelp logo

express-file-upload's Introduction

Express-upload-amazon-s3

Sample project for demonstrating how to upload file from web through express to Amazon S3 (Simple Storage Service) by aws-sdk

  • Edit /config.json
{
    "accessKeyId": "XXXXXXXXXXXXXXXXXXX",
    "secretAccessKey": 	"XXXXXXXXXXXXXXXXXXXXXXXXX",
    "region": "us-east-1"
}
  • Edit /routes/upload.js, update the value of Bucket to your bucket name.
s3.putObject({
    Bucket: 'XXXXX Bucket Name', //S3 Bucket Name
    Key: file.originalname, //Upload File Name, Default the original name
    Body: data
}, this);
  • Start server node app.js

Now check http://localhost:3000

Error Handling

[S3] PermanentRedirect

PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

Solution: The region settings might be wrong, please check your config.json and make sure the region is correct

[S3] AccessDenied 403

[AccessDenied: Access Denied]

Solution: Try update your S3 Bucket's CORS Configuration to following

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
   <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

Reference

express-file-upload's People

Contributors

vishisth29 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.