If you are just looking to create presigned url, you can use getSignedUrlPromise
method that returns promise
exports.handler = async (event) => {
return s3.getSignedUrlPromise("putObject", {
Bucket: "my bucket",
Key: "my file name",
ContentType: "some file type",
});
};
If you need customize the response
exports.handler = async (event) => {
return new Promise((resolve, reject) => {
s3.getSignedUrl(
"putObject",
{
Bucket: "my bucket",
Key: "my file name",
ContentType: "some file type",
},
(err, url) => {
if (err) reject(err);
if (url)
resolve({
statusCode: 200,
body: url,
});
});
});
};
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…