8000 Allow passing custom query params · Issue #8 · wojtekmach/req_s3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow passing custom query params #8

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

Open
venkatd opened this issue Aug 21, 2024 · 4 comments
Open

Allow passing custom query params #8

venkatd opened this issue Aug 21, 2024 · 4 comments

Comments

@venkatd
Copy link
venkatd commented Aug 21, 2024

I am trying to move to a lighter abstraction and req_s3 seems great!

One thing in the way of that is that I am not able to pass in custom query_params.

You can see it's implemented here in ex_aws:
https://github.com/ex-aws/ex_aws/blob/8020fa1c0a7221c3931a91ec8089e52c868667c0/lib/ex_aws/auth.ex#L76

It gets merged into the canonical params. I noticed Req.Utils contains the logic to sign S3 requests, but perhaps that should belong in req_s3 before any improvements are made?

@wojtekmach
Copy link
Owner

Hey Venkat! Which functions are you using? These should both work today:

Req.get!(req, url: "s3://bucket1?versions")
ReqS3.presign_url(url: "s3://bucket1?versions")

The only one without a workaround is ReqS3.presign_form/1 I believe.

In any case, yes, we should definitely support it, PRs would be very appreciated.

I might end up regretting it in the long run, but I'd prefer to keep majority of AWS signature logic in Req proper since we use some of it there. We should add a :query or similar option.

@wojtekmach
Copy link
Owner

Edit: nevermind, ReqS3.presign_url(url: "s3://bucket1?versions") does not work today.

@venkatd
Copy link
Author
venkatd commented Aug 21, 2024

Hi!

I was using ReqS3.presign_url([bucket: bucket, key: key] ++ options) and it works as expected :)

The use case is that our app has an option to either download a file or view it in a PDF viewer directly in the browser. So I need to generate two pre-signed urls:

The one that forces a download would ideally look like so:

ReqS3.presign_url([
  bucket: bucket, 
  key: key, 
  query: [{"response-content-disposition", "attachment; filename=#{filename}"}]
] ++ s3_options)

I'm happy to give a PR a try later this month. I need to study the ex_aws implementation a bit because there are some details on how to sort the query params.

It seems like the bulk of the changes would be in &Req.Utils.aws_sigv4_url/1 if I'm not mistaken

@wojtekmach
Copy link
Owner

Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0