I have a function that makes an API request containing the URL of a new file I just uploaded to AWS S3. And I have one function that only upload the file to S3. I am having issues with returning this URL of the uploaded file. Here is my code: Here is the SDK doc with the upload example: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
Tag: aws-sdk
Jest skipping S3 Get Object call in function
Im testing a standard S3 Get Object Call, but when Jest tests my function, it skips the Get Object call and jumps to end of function, ending the execution and returning nothing. When I checked code coverage, all lines are covered expect the getObject call. This is my s3 file being tested. I have checkpoints there to show that the
Get AWS S3 Upload URL – NodeJs AWS-SDK
I’m pretty sure I’m missing something very obvious here, but: I’m uploading a file to an s3 bucket using aws-sdk as follows: I’m able to log the upload url successfully, however the awsURL returned is an array, not the data.Location value – shouldn’t the data.Location be returned from the callback? Answer Convert s3.upload to return a promise:
How to track upload progress to S3 using aws-sdk V3 for browser (javascript)
I can find a lot of resources online on how to track upload progress to S3 using aws-sdk V2, listening to the event like: But since I updated the aws-sdk to V3, there are no listeners anymore. I believe I have to use the middleware function now, but I’ve tried a few things and it didn’t work. I’ve also went
How do I test if a bucket exists on AWS S3
How do I test if a bucket exists on AWS S3 using the aws-sdk? This question is for testing if an object exists within a bucket: How to determine if object exists AWS S3 Node.JS sdk This question is for Python: How can I check that a AWS S3 bucket exists? Answer You can use the following code: The important
Mock a dependency’s constructor Jest
I’m a newbie to Jest. I’ve managed to mock my own stuff, but seem to be stuck mocking a module. Specifically constructors. usage.js I’d like to do something like this in the tests. However when I come to use it in usage.js the cw is a mockConstructor not a FakeMetrics I realise that my approach might be ‘less than idiomatic’
How to use the code returned from Cognito to get AWS credentials?
Right now, I’m struggling to understand AWS Cognito so maybe someone could help me out. I set a domain to serve Cognito’s hosted UI for my User Pool like what’s described here. So when I go to https://<my-domain>.auth.us-east-1.amazoncognito.com/login?response_type=code&client_id=<MY_POOL_CLIENT_ID>&redirect_uri=https://localhost:8080 I get a login page where my users can login to my app with Google. That part is working great. I’m confused
How to copy/move all objects in Amazon S3 from one prefix to other using the AWS SDK for Node.js
How do I copy all objects from one prefix to other? I have tried all possible ways to copy all objects in one shot from one prefix to other, but the only way that seems to work is by looping over a list of objects and copying them one by one. This is really inefficient. If I have hundreds of
AWS S3 JavaScript SDK getSignedUrl returns base path only
I have some very simple code for generating an S3 URL. The URL I get back from the SDK only has the base path for S3. It doesn’t contain anything else. Why is this happening? Node.js v0.12.0, AWS SDK 2.1.15 or 2.1.17, Windows 7 64-bit, Answer The problem wasn’t with code. It turns out that when you don’t have your