aws-sdk-js: Error : s3.upload.promise() is not a funciton
I’m trying to call the setPromisesAWS.config.setPromisesDependency config function but my config object doesn’t seem to have the setPromisesDependency property. Am I missing something?
AWS.config.setPromisesDependency(bluebird)
// Error : AWS.config.setPromisesDependency is not a function
I have version 2.2.48 installed via bower. Any help would be appreciated.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 21 (6 by maintainers)
Hi @dhatawesomedude
Promises are currently only supported on operations that return a Request object. Since
s3.upload
is a custom function that returns an instance of ManagedUpload rather than Request, promises are not currently supported for that operation. However, this is a feature request that we are looking into.As a current workaround, if you know your file’s size, you can use the
putObject
operation for file sizes <= 5MB, or use the multipart upload operations for file sizes greater than 5MB. The SDK does support promises on all of these operations. You could also create the promise:I hope that helps!
One last response and then I’ll leave it for you to discuss in https://github.com/aws/aws-sdk-js/issues/1650 as suggested by @jeskew
@niftylettuce I am using code similar to you and am not getting an error:
Good luck.
Hi @dhatawesomedude
Thanks for your question. Promises are not supported in the SDK prior to version
2.3.0
. If you update to2.3.0
or later, thesetPromisesDependency
property will be onAWS.config
.As an update, I believe promises are now supported on ManagedUploads so
upload
can be used instead ofputObject
if so desired: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3/ManagedUpload.html#promise-propertyYes I know that, I’m saying that there’s somewhere in the AWS SDK where there is a promise that is not wrapped with a try catch. In my code I wrapped it with a try catch and STILL got an unhandled promise rejection. I’m on latest Node, which is 6.6.x.
Another way to do this in the meanwhile is to use
es6-promisify
at https://www.npmjs.com/package/es6-promisify. Here’s an example:… or if you’re not using async/await …