[英]my graphql resolver with aws s3 functions returning h18 error on heroku?
my code is like this:我的代码是这样的:
try {
s3.putObject(params);
await admin.auth().updateUser(contextUser.uid, {
photoURL: awsPhotoURL,
});
if (contextUser.picture) s3.deleteObject(deleteParams);
return {
message: 'Success',
success: true,
file,
fileName,
};
} catch (error) {
console.log('error: ', error);
return {
message: error.message,
success: false,
file: null,
fileName: null,
};
}
basically i don't get an error on localhost, upload operation working as expected but i am getting h18 error once it's already on production.基本上我在本地主机上没有收到错误,上传操作按预期工作,但是一旦它已经投入生产,我就会收到 h18 错误。 I tried to put await on s3 operations like this:
我试图将 await 放在这样的 s3 操作上:
await s3.putObject(params);
but i would get warning such as:但我会收到警告,例如:
'await' has no effect on the type of this expression.
'await' 对这个表达式的类型没有影响。
what's wrong with my code?我的代码有什么问题?
To use promises/await with the aws-sdk
you will need to use the promisified version as such:要将 promises/await 与
aws-sdk
一起使用,您需要使用 promisified 版本:
s3.putObject(params).promise()
Then await
should work as expected.然后
await
应该按预期工作。
Check out docs on promises here (actually has a S3.putObject() example)在此处查看有关承诺的文档(实际上有一个 S3.putObject() 示例)
I am not sure this will solve your actual problem but it's a start.我不确定这会解决您的实际问题,但这是一个开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.