1.0.0 • Published 12 months ago

@mahdi.golzar/fileuploader v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

FileUploader

FileUploader is a versatile tool designed for uploading files to various storage systems. It supports local storage, AWS S3, and Google Cloud Storage, with easy-to-use methods for file uploading.

Features

  • Multiple Storage Types: Supports local file storage, AWS S3, and Google Cloud Storage.
  • Dynamic Configuration: Easily switch between different storage systems with dynamic configuration.
  • Simple Upload Method: Upload files using a unified method.

Installation

Install the required dependencies:

npm install aws-sdk @google-cloud/storage

Usage

  1. Create a FileUploader Instance
    const uploader = new FileUploader();
  2. Configure and Upload Files Local Storage
    uploader.useStorage('local', { path: './uploads' });
    uploader.upload('./example.txt', 'example.txt');
    AWS S3 Storage
    uploader.useStorage('s3', {
    accessKeyId: 'YOUR_AWS_ACCESS_KEY_ID',
    secretAccessKey: 'YOUR_AWS_SECRET_ACCESS_KEY',
    region: 'YOUR_AWS_REGION',
    bucketName: 'YOUR_S3_BUCKET_NAME'
    });
    uploader.upload('./example.txt', 'example.txt');
    Google Cloud Storage
    uploader.useStorage('gcs', {
    projectId: 'YOUR_GCS_PROJECT_ID',
    keyFilename: 'path/to/your-service-account-key.json',
    bucketName: 'YOUR_GCS_BUCKET_NAME'
    });
    uploader.upload('./example.txt', 'example.txt');
1.0.0

12 months ago