Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ericlewis966/aws-s3-mangement-express-server
express application uploads multi part form data (file) on aws Simple Storage Service (S3)
https://github.com/ericlewis966/aws-s3-mangement-express-server
amazon aws aws-s3 express nodejs s3 s3-bucket
Last synced: about 6 hours ago
JSON representation
express application uploads multi part form data (file) on aws Simple Storage Service (S3)
- Host: GitHub
- URL: https://github.com/ericlewis966/aws-s3-mangement-express-server
- Owner: ericlewis966
- License: mit
- Created: 2022-06-29T23:42:19.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-06-29T23:43:14.000Z (over 2 years ago)
- Last Synced: 2023-07-19T03:08:22.629Z (over 1 year ago)
- Topics: amazon, aws, aws-s3, express, nodejs, s3, s3-bucket
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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](https://github.com/aws/aws-sdk-js)
## Setup
##### 1.Download Project
```bash
git clone https://github.com/ryanhanwu/express-upload-amazon-s3.git
```
##### 2.Install required packages
```bash
npm install
```##### 3.Update Amazon Crenditials
* Edit ```/config.json```
```json
{
"accessKeyId": "XXXXXXXXXXXXXXXXXXX",
"secretAccessKey": "XXXXXXXXXXXXXXXXXXXXXXXXX",
"region": "us-east-1"
}
```##### 4.Update Bucket Name
* Edit ```/routes/upload.js```, update the value of **Bucket** to your bucket name.
```javascript
s3.putObject({
Bucket: 'XXXXX Bucket Name', //S3 Bucket Name
Key: file.originalname, //Upload File Name, Default the original name
Body: data
}, this);
```##### 5.Start server
node app.jsNow check [http://localhost:3000](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
*
GET
POST
PUT
*
```
## Reference
* Document From Amazon
* [Security Credentials](https://console.aws.amazon.com/iam/home?#security_credential)
* [AWS JavaScript SDK - S3 Client](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property)