'Sequelize get function with AWS SDK Promise
I'm upgrading from AWS SDK v2 to v3 and am unable to presign urls within the model get functions. I am using the same version of Sequelize (6.13.0) in both instances.
This worked with AWS SDK v2:
Model
s3image: {
type: type.STRING,
get: function() {
let str = this.getDataValue('s3image');
str = presignUrl(str);
return str;
},
},
AWS SDK v2 Presign
let signedUrl = s3.getSignedUrl('getObject', {
Bucket: __bucket__,
Key: __str__,
Expires: 3600
})
return signedUrl;
When I try to attempt the same thing with v3 it's returning the Promise; Sequelize doesn't wait for it to finish. I've tested with simple timeouts and the get function doesn't seem to wait for anything, it will just return null or not send the column back at all.
Things I've tried:
let command = new GetObjectCommand({
Bucket: __bucket__,
Key: str
});
getSignedUrl(client, command, { expiresIn: 3600 }).then((url) => {
console.log(url)
return url;
})
const url = async () => {
await presignUrl(str);
}
return url;
Is there a way to achieve this with AWS SDK v3?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
