1回答
- 新しい順
- 投票が多い順
- コメントが多い順
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
回答済み 2年前
関連するコンテンツ
- AWS公式更新しました 3年前