Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3.getSignedUrl() keeps returning undefined #166

Closed
marcosCapistrano opened this issue Sep 11, 2021 · 4 comments
Closed

s3.getSignedUrl() keeps returning undefined #166

marcosCapistrano opened this issue Sep 11, 2021 · 4 comments
Assignees
Labels
Assigned - Async Issue is assigned to at least one person. PR is assigned to at least one person. Ready to test - Async Issue is implemented and ready for testing. PR is merged.

Comments

@marcosCapistrano
Copy link

marcosCapistrano commented Sep 11, 2021

Not sure if im doing something wrong, tried it a bunch of times and it keeps returning undefined here:

return new Promise((resolve, reject) => {
s3.getSignedUrl('putObject', params, (err, data) => {
const parsedUrl = url.parse(data); <<<<<<<<<<< HERE "data" is undefined

  const returnData = {
    signedRequest: data,
    url: `${parsedUrl.protocol}//${parsedUrl.hostname}${parsedUrl.pathname}`,
  };

  if (err) {
    console.error(err);
    reject(err);
  } else {
    resolve(returnData);
  }
});

});

Files from 5-begin can be used for testing

@klyburke
Copy link
Member

@marcosCapistrano Thanks for reporting. I will run 5-begin and see if I can reproduce the error.

@klyburke klyburke self-assigned this Sep 14, 2021
@klyburke
Copy link
Member

klyburke commented Sep 15, 2021

@marcosCapistrano I ran the 5-begin code and did not see that data in that line of code is undefined.

To confirm that data is not undefined here, I went to the aws-s3.ts file of 5-begin and added console.log(data) like so:

Screenshot from 2021-09-14 14-10-44

I started the app, went to Your Settings page and uploaded a new avatar. After that, my server logs print data object:

Group 141


Please check up set up for your AWS S3 bucket. Under Permissions, make sure you deselected Block all public access:

Screenshot from 2021-09-14 14-28-12

Also under Permissions, make sure your CORS policy is correct:

Screenshot from 2021-09-14 14-30-43

Finally, check that you have all necessary environmental variables saved in your appropriate .env files (both app and api).


Let me know if you still have trouble. Feel free to create a public repo with your code, and I will test.

@marcosCapistrano
Copy link
Author

Oh i must have done something wrong, i'll try it as soon as I can, Thanks!!

@klyburke
Copy link
Member

Hi @marcosCapistrano - were you able to figure out the issue? Let me know if you still have trouble.

@tima101 tima101 closed this as completed Nov 30, 2021
@tima101 tima101 added Assigned - Async Issue is assigned to at least one person. PR is assigned to at least one person. Ready to test - Async Issue is implemented and ready for testing. PR is merged. labels Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Assigned - Async Issue is assigned to at least one person. PR is assigned to at least one person. Ready to test - Async Issue is implemented and ready for testing. PR is merged.
Projects
None yet
Development

No branches or pull requests

3 participants