@lesfabricants/express-proxyfile
v1.0.2
Published
A simple library to replace any current express application that uses the file system to serve files to switch to a cloud service
Downloads
1
Keywords
Readme
express-proxyfile
a simple library to replace any current express application that uses the file system to serve files to switch to a cloud service
Installation
npm i @lesfabricants/express-proxyfile
In your application you use it as a middleware:
import {proxyFile} from "@lesfabricants/express-proxyfile";
//...
app = express();
app.use(proxyFile(myCloudHandler));
//...
app.get('/:somefiles', (req, res) => {
res.sendFile('path to my file');
});
BuildIn Handler
S3 Object storage
import {s3Proxy} from "@lesfabricants/express-proxyfile";
//...
app = express();
app.use(s3Proxy({
// Your S3 config
endpoint: process.env.STORAGE_ENDPOINT,
credentials: {
accessKeyId: process.env.STORAGE_API_KEY,
secretAccessKey: process.env.STORAGE_API_SECRET
},
region: process.env.STORAGE_REGION
}, "myBucketName"));
//...
app.get('/:somefiles', (req, res) => {
res.sendFile('path to my file');
});