import * as fs from "fs";
import * as AWS from "aws-sdk";
const BUCKET_NAME = "<<bucket-name>>";
const IAM_USER_KEY = "<<user-key>>";
const IAM_USER_SECRET = "<<user-secret>>";
const s3bucket = new AWS.S3({
accessKeyId: IAM_USER_KEY,
secretAccessKey: IAM_USER_SECRET
});
export function downloadToS3(fileName: string): Promise<any> {
const params = {
Bucket: BUCKET_NAME,
Key: "myapp" + "/" + filename,
};
s3bucket.getObject(params, function (err, data) {
if (err) {
console.log("error!");
}
else {
fs.createWriteStream(filename).write(data.Body);
console.log(data.Body);
}
});
return new Promise((resolve, reject) => {
});
}
downloadToS3("<<filename>>")
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)