@uploadx/gcs
v7.0.0
Published
Uploadx GCS module
Maintainers
Readme
@uploadx/gcs
Google Cloud Storage provider for node-uploadx.
Installation
npm install @uploadx/gcsUsage (Express)
import express from 'express';
import { uploadx } from '@uploadx/core';
import { GCStorage } from '@uploadx/gcs';
const app = express();
const storage = new GCStorage({
bucket: 'my-bucket',
maxFileSize: '1GB',
allowedMimeTypes: ['image/*', 'video/*'],
onComplete: file => console.log('Upload complete:', file)
});
app.use('/files', uploadx({ storage }));
app.listen(process.env.PORT || 3002, () => console.log('Server started'));Package-Specific Options
| Option | Type | Description |
| -------------------- | --------- | ------------------------------------------------------------ |
| bucket | string | GCS bucket name (env: GCS_BUCKET, default: 'node-uploadx') |
| keyFile | string | Path to service account key file (env: GCS_KEYFILE) |
| clientDirectUpload | boolean | Force client to upload directly to GCS via resumable URI |
See @uploadx/core and GoogleAuth for additional options.
Environment Variables
GCS_BUCKET- Google Cloud Storage bucket nameGCS_KEYFILE- Path to service account JSON key fileGCS_UPLOAD_API- Custom upload API endpointGCS_STORAGE_API- Custom storage API endpointSTORAGE_EMULATOR_HOST- GCS emulator host for local development
Get service account credentials from Google Cloud Console.
Example .env
GCS_BUCKET=node-uploadx.appspot.com
GCS_KEYFILE=~/.gcs-credentials.jsonFull Documentation
See the main node-uploadx repository for complete documentation.
License
MIT
