Is there a way i can send bucket event notifications to my callback url after uploading to R2 Bucket?

i am really looking for a way to connect R2 Bucket upload to my backend service

Welcome to the Cloudflare Community!

R2 has no callbacks or notifications for bucket actions at the moment.
If you handle uploads (multipart or normal) through a Cloudflare Worker: Use the R2 multipart API from Workers · Cloudflare R2 docs, you could create your own notifications/call any callback url.
Or you could just have your user call your API after the upload is complete and check it.

i wanted to generate signed urls which call my backend api upon upload completion .Is there a way i can achieve that

No way to make R2 call your backend API for you. You’d have to make the client do it.

Thanks for that. Seems like i will have to my callback on my own after file upload is completed on my frontend app via the signed urls .

1 Like

If i may ask is there a way i can check if a file exists in r2 storage from a cloudflare worker

You can, yea. Using R2 Bindings in a Worker you can do every operation (HEAD, GET, PUT, DELETE, LIST, Multipart):

You’d just do a HEAD or a GET and check if the R2Object returned is null

when making the head request is the key the filename that i am trying to upload so that i can append a uuid to the file to prevent replacement of existing file

Key is filename yep, folders/etc are all virtual, so it’d be the entire path if that makes sense, ex: key might be cookies/2023/11/02/newcookie.jpg