1 réponse
- Le plus récent
- Le plus de votes
- La plupart des commentaires
1
Achieved it through:
require("dotenv").config();
const aws = require('aws-sdk');
const expres = require("express");
const app = expres();
app.listen(3001);
app.get('/getfilefromS3', async (req, res, next) => {
aws.config.update({
secretAccessKey: process.env.ACCESS_SECRET,
accessKeyId: process.env.ACCESS_KEY,
region: process.env.REGION
})
const s3 = new aws.S3(secretAccessKey = process.env.ACCESS_SECRET, accessKeyId = process.env.ACCESS_KEY);
var params = { Bucket: process.env.BUCKET, Key: "connect/oblab2/CallRecordings/2022/04/08/" + req.query.filename };
s3.getObject(params, function (err, data) {
if (err) {
res.status(200);
res.end('Error Fetching File');
}
else {
res.attachment(params.Key); // Set Filename
res.type(data.ContentType); // Set FileType
res.send(data.Body); // Send File Buffer
}
});
})```
And than hitting endpoint:
http://localhost:3001/getfilefromS3?filename=filename.wav
répondu il y a 2 ans
Contenus pertinents
- demandé il y a 17 jours
- demandé il y a 6 mois
- demandé il y a 2 mois
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a un an