a
Hi, Is it possible to directly upload files from browser to R2? If its not supported, what is the preferred way to upload user files from browser to R2?
The only way we can upload the user files to R2 is by using a Worker as proxy?
k
Do you want users to upload files to your R2 bucket or you uploading files to your bucket?
For the first one you could use the S3-compatible API with Presigned URLs to let users upload files to your bucket. For the second one there is a possibility to upload files (up to 300MB) via the Dashboard.
a
@kev-ac - Thanks for the reply. I want my application users to upload files to R2 bucket. With reference to "S3-compatible API with Presigned URLs" : This will be a 2 step process, where we generate presigned URL first and using the presigned URL, upload the actual file. Is my assumption correct?
k
It depends. You can do two things: - Let the users upload the files directly from the browser to the R2 bucket -> Presigned URL - Let the users upload files to your server and from there upload them to the R2 Bucket -> R2 credentials
The difference is: With the presigned URL you generate a kind of "restricted" access token to your bucket with your R2 credentials. The restricted token can only access the exact path and method you specify while your R2 credentials can access all of your buckets. You never want to expose your R2 credentials anywhere to your users.
With a presigned URL you say for example: Your user is allowed to do a
PutObject
command on my bucket
appbucket
for the key (filepath)
user-uploads/123456.jpg
for the next 120 seconds.
a
Makes sense. Thanks @kev-ac