npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

file-uploader-js3

v1.0.1

Published

File upload support for multiple storage backends allows for flexibility in managing and storing files across different platforms. This feature enables file uploads to be seamlessly handled by various storage solutions such as the local filesystem, AWS S3

Downloads

9

Readme

FileUploader

File upload support for multiple storage backends provides flexibility by allowing uploads to be handled across different platforms like local filesystems, AWS S3, or Google Cloud Storage. This feature ensures secure, scalable, and efficient file storage tailored to users' needs.

Features

  • Middleware for handling file uploads in Express.
  • Support for multiple file storage backends (local filesystem, AWS S3, Google Cloud Storage).
  • File validation (size, type, etc.).
  • Chunked uploads for large files.
  • Image processing and resizing utilities.

Installation

npm install file-uploader-js3

Usage

Middleware

const express = require('express');
const { fileUpload } = require('file-uploader-js3');

const app = express();

// Local storage
const upload = fileUpload('local', { destination: 'uploads/' });

app.post('/upload', upload.single('file'), (req, res) => {
  res.send('File uploaded successfully');
});

app.listen(3000, () => {
  console.log('Server started on port 3000');
});

// AWS S3 storage
const upload = fileUpload('s3', {
  bucket: 'your-bucket-name',
});

app.post('/upload', upload.single('file'), (req, res) => {
  res.send('File uploaded successfully');
});

app.listen(3000, () => {
  console.log('Server started on port 3000');
});

// Google Cloud Storage (GCS) storage
const upload = fileUpload('gcs', {
  bucket: 'your-bucket-name',
});

app.post('/upload', upload.single('file'), (req, res) => {
  res.send('File uploaded successfully');
});

app.listen(3000, () => {
  console.log('Server started on port 3000');
});

File Validation

const { validateFile } = require('file-uploader-js3');

const options = {
  maxSize: 1024 * 1024, // 1 MB
  allowedTypes: ['image/jpeg', 'image/png'],
};

try {
  validateFile(req.file, options);
  // Continue processing the file
} catch (error) {
  res.status(400).send(error.message);
}

Image Processing

const { resizeImage } = require('file-uploader-js3');
const fs = require('fs');

const buffer = fs.readFileSync('path/to/image.jpg');

resizeImage(buffer, 200, 200)
  .then((resizedBuffer) => {
    fs.writeFileSync('path/to/resized_image.jpg', resizedBuffer);
  })
  .catch((error) => {
    console.error(error);
  });

AWS S3 storage .env

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=

Google Cloud Storage (GCS) storage .env

GCP_PROJECT_ID=
GCP_KEY_FILE=

License

GNU GENERAL PUBLIC LICENSE

The GNU General Public License (GPL) is a widely used free software license that guarantees end users the freedom to run, study, share, and modify the software. Key features of the GPL include:

Freedom to Use: Users can run the software for any purpose. Freedom to Study and Modify: Users can study how the program works and change it to suit their needs. Access to the source code is required. Freedom to Distribute Copies: Users can redistribute the original software to others.

reedom to Distribute Modified Versions: Users can distribute copies of the modified software, allowing the community to benefit from improvements. Access to the source code of modified versions is required. The GPL aims to promote and protect software freedom by ensuring that software remains free and open. Any derivative work must also be licensed under the GPL, ensuring that the same freedoms are preserved.**

For the full text of the GPL, you can refer to the GNU General Public License website.