a simple library to replace any current express application that uses the file system to serve files to switch to a cloud service
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');
});
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');
});