Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@nmwh917/multer-google-storage
Advanced tools
Streaming multer storage engine for Google Cloud Storage
This is a multer storage engine for google's file storage.
npm install multer-google-storage --save
or
yarn add multer-google-storage
import * as multer from 'multer';
import * as express from 'express';
import MulterGoogleCloudStorage from 'multer-google-storage';
const app = express();
const uploadHandler = multer({
storage: new MulterGoogleCloudStorage()
});
app.post('/upload', uploadHandler.any(), (req, res) => {
console.log(req.files);
res.json(req.files);
});
var multer = require("multer");
var express = require("express");
var multerGoogleStorage = require("multer-google-storage");
var app = express();
var uploadHandler = multer({
storage: multerGoogleStorage.storageEngine()
});
app.post('/upload', uploadHandler.any(), function (req, res) {
console.log(req.files);
res.json(req.files);
});
NB: This package is written to work with es5 or higher. If you have an editor or IDE that can understand d.ts (typescript) type definitions you will get additional support from your tooling though you do not need to be using typescript to use this package.
For instructions on how to create a storage bucket see the following documentation from google.
For instructions on how to obtain the JSON keyfile as well a "projectId" (contained in the key file) please refer to the following documentation from google
If using the MulterGoogleCloudStorage class without passing in any configuration options then the following environment variables will need to be set:
The constructor of the MulterGoogleCloudStorage class can be passed an optional configuration object.
Parameter Name | Type | Sample Value |
---|---|---|
autoRetry | boolean | true |
email | string | "test@test.com" |
keyFilename | string | "./key.json" |
maxRetries | number | 2 |
projectId | string | "test-prj-1234" |
filename | function | (request, file, callback): void |
bucket | string | "mybucketname" |
contentType | function | (request, file): string |
acl | string | "publicread" |
If you need to customize the naming of files then you are able to provide a function that will be called before uploading the file. The third argument of the function must be a standard node callback so pass any error in the first argument (or null on sucess) and the string name of the file on success.
getFilename(req, file, cb) {
cb(null,`${uuid()}_${file.originalname}`);
}
FAQs
Streaming multer storage engine for Google Cloud Storage
We found that @nmwh917/multer-google-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.