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

[R2] Clarify Presigned URL docs #19190

Open
harshil1712 opened this issue Jan 14, 2025 · 3 comments
Open

[R2] Clarify Presigned URL docs #19190

harshil1712 opened this issue Jan 14, 2025 · 3 comments
Assignees
Labels
content:edit Request for content edits documentation Documentation edits product:r2 R2 object storage: https://developers.cloudflare.com/r2

Comments

@harshil1712
Copy link
Contributor

Existing documentation URL(s)

What changes are you suggesting?

Developers have reported issues understanding how to use Presigned URL for R2. One of the feedback we have got is the confusion on using Presigned URLs outside of the Workers environment. We need to audit the documentation and make any changes required.

From the developer:

Yeah, I did notice that after reading through the entire documentation and those linked pages. The confusing part is the *flow* of the documentation, not necessarily its contents. It went something like this:

1. Search for presigning of urls using R2, with the purpose being to let users upload from a browser, directly to R2
2. Find this page at the top of any kind of search result
3. Find a section dedicated to Workers, think "oh yeah, I'm using that - this is for me" (see image)
4. Become very confused and go down a rabbit hole of various issues, since this section, was, in fact, not for me

Another tidbit is that example here uses `aws4fetch` in the workers example, and none of the other examples use this client. The assumption then is that this is the only client that works with Workers, because:
- This is generally the case with fetch/web-compatible libraries compared to nodejs/other js ones
- The word "alternative" in the section title carries weight with it, signals that other approaches *do not work* when using Workers

I *think* thats the full extent of the confusion. Some of it is pedantic but may still be valuable to take a look over and see if you can clarify. I also think an example section dedicated to this use case (presign R2 url from worker, upload to it with cURL or something) could be really helpful, since it's not the first time someone has gone through the same process & issues as me here on Discord.

Additional information

One can find more information in this Discord thread: https://discord.com/channels/595317990191398933/1327764577630421002/1328414674642931786

@harshil1712 harshil1712 added content:edit Request for content edits documentation Documentation edits product:r2 R2 object storage: https://developers.cloudflare.com/r2 labels Jan 14, 2025
@harshil1712 harshil1712 self-assigned this Jan 14, 2025
@Jbithell
Copy link

Jbithell commented Jan 26, 2025

I found this line particualrly confusing - as in the worker code token secrets are present and no bindings are present:

Notice the total absence of any configuration or token secrets present in the Worker code. Instead, you would create a wrangler.toml binding to whatever bucket represents the bucket you will upload to. Additionally, authorization is handled in-line with the upload which can reduce latency.

The example shown does not handle authorization in-line at all, it generates a signed request

https://discord.com/channels/595317990191398933/940663374377783388/1327757266119561237

@oeed
Copy link

oeed commented Feb 23, 2025

Yeah I've been confused by that section of the docs too.

My goal in reading that section was to generate a presigned URL which clients (i.e. browsers, not other workers) could use to directly upload to the bucket, rather than needing to upload via a worker. The docs suggest that you don't need to use an access key, or a bucket URL, but they'll be magically populated due to the binding. Yet there's no use of the binding, and seemingly no way to access the bucket URL from it.

@danieljvdm
Copy link

I also just about blew my brains out reading these docs at 1am... I'm assuming that there's actually no way to generate a presigned url just using the r2 binding and I'll need to include my r2 bucket credentials in the env and create the presigned url the old fashioned way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content:edit Request for content edits documentation Documentation edits product:r2 R2 object storage: https://developers.cloudflare.com/r2
Projects
None yet
Development

No branches or pull requests

7 participants