You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Create a Cloudflare account](https://cloudflare.com)
30
30
-[Create an R2 bucket](https://developers.cloudflare.com/r2/buckets/create-buckets/)
31
31
- Set the bucket name as an environment variable `R2_BUCKET` in your Convex
32
-
deployment
33
-
-[Add a CORS policy](https://developers.cloudflare.com/r2/buckets/cors/#add-cors-policies-from-the-dashboard) to the bucket allowing GET and PUT requests from your
34
-
Convex app. You can also use '\*' to allow all origins (use with caution).
32
+
deployment via `npx convex env set R2_BUCKET <bucket-name>`.
33
+
-[Add a CORS policy](https://developers.cloudflare.com/r2/buckets/cors/#add-cors-policies-from-the-dashboard)
34
+
to the bucket allowing GET and PUT requests from your Convex app. You can also
Files can be stored in R2 directly from actions using the `r2.store` method. This is useful when you need to store files that are generated or downloaded on the server side.
249
+
Files can be stored in R2 directly from actions using the `r2.store` method.
250
+
This is useful when you need to store files that are generated or downloaded on
251
+
the server side.
245
252
246
253
```ts
247
254
// convex/example.ts
@@ -280,11 +287,13 @@ The `store` method:
280
287
281
288
## Serving Files
282
289
283
-
Files stored in R2 can be served to your users by generating a URL pointing to a given file.
290
+
Files stored in R2 can be served to your users by generating a URL pointing to a
291
+
given file.
284
292
285
293
### Generating file URLs in queries
286
294
287
-
The simplest way to serve files is to return URLs along with other data required by your app from queries and mutations.
295
+
The simplest way to serve files is to return URLs along with other data required
296
+
by your app from queries and mutations.
288
297
289
298
A file URL can be generated from a object key by the `r2.getUrl` function of the
290
299
R2 component client.
@@ -311,9 +320,9 @@ export const list = query({
311
320
{
312
321
// Custom expiration time in seconds, default is 900 (15 minutes)
0 commit comments