Giter Site home page Giter Site logo

s3-upload-api's Introduction

Node.js File Upload to Amazon S3

This Node.js application provides a simple API endpoint for uploading files to Amazon S3 using the AWS SDK v3. It utilizes Express.js for handling HTTP requests, Multer for handling file uploads, and the aws-sdk library for interacting with Amazon S3.

Prerequisites

Before getting started, ensure you have the following installed on your machine:

  • Node.js
  • npm (Node Package Manager)

Installation

  1. Clone the repository:

    git clone https://github.com/abdoil/s3-upload-API.git
    
  2. Navigate to the project directory:

    cd your-repo
    
  3. Install dependencies:

    npm install
    
  4. Create a .env file in the project root and add your AWS credentials:

    AWS_ACCESS_KEY_ID=your-access-key
    AWS_SECRET_ACCESS_KEY=your-secret-key
    AWS_BUCKET_NAME=your-s3-bucket-name 
    
    

Usage

  1. Start the server:

    node index.js
    
  2. Make a POST request to http://localhost:3000/upload with one or more files attached.

    Example using curl:

    curl -X POST -F "file=@/path/to/your/file.txt" http://localhost:3000/upload
    
  3. The server will upload the file(s) to Amazon S3, and the response will be a JSON object containing the status and the modified keys:

    {
      "status": "success",
      "modifiedKeys": [
        "https://your-s3-bucket-url/uploads/your-uuid-filename.txt"
      ]
    } 
    
    

Configuration

Adjust the AWS configuration and other settings in the .env file.

Contributing

Feel free to contribute by opening issues or creating pull requests.

s3-upload-api's People

Contributors

abdoil avatar

Watchers

 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.