Emulating R2 locally
Hello! The R2/worker docs state:
By default wrangler dev runs in local development mode. In this mode, all operations performed by your local worker will operate against local storage on your machine.
I have a worker pulling files from R2, so no problems there. Also the wrangler deploy is quick, so generally I have no need of local storage. I am curious however what "operate against local storage on your machine" means. Is the general idea that we will setup env.BUCKET_NAME
to point to some local folder to make this work? Does the R2 get (e.g. env.BUCKET_NAME.get()
) somehow grok this local filesystem link?2 Replies
Correct. Local means that it will emulate the R2 binding with your local file system. It does this so you don't incur costs or effect your production bucket. You can choose to use the remote resources by adding
--remote
flag to wrangler dev
commandOh wow. Interesting. I've been using
npm run dev
and npm run deploy
with the vite plugin. Forgot all about wrangler dev
- thanks for the reminder. I will try that out, now. It's already working - it barked at me to create a dev bucket 😆
Thanks @Cyb3r-Jak3: --remote
is really what I was looking for, but the local link works fine 👍