Wrangler r2 object put, get, and delete not doing anything locally
I have upload a file using
wrangler r2 object put project/test.pdf --file=/Users/me/Downloads/test.pdf --local
and it tells me Creating object "test.pdf" in bucket "project". Upload complete.
But then when I run wrangler r2 object get project/test.pdf
, it tells me ✘ [ERROR] The specified key does not exist.
However when I run the code const listed = await context.env.MY_BUCKET.list(); console.log('Files in bucket:', listed.objects.map(obj => obj.key));
with my wrangler.toml containing [[r2_buckets]] binding = "MY_BUCKET" bucket_name = "project"
it does contain test.pdf in the list of files. So how can I fix this?
Note that wrangler r2 object delete project/test.pdf
gives me a success code but then the file is still in the list I generate above.7 Replies
--local = interact with locally simulated bucket (supported on all r2 object commands)
wrangler dev = local resources by default
If you leave the --local off the wrangler r2 commands, you're talking to live bucket
If you add --remote to dev, you're talking to live resources
This problem persists even when I use --local in all commands.
@Chaika
I can't reproduce that if I properly use --local in all commands, ex:
I would make sure you're on the latest wrangler version
side note: Delete will always work on remote bucket (without local) even if the file doesn't exist
@Chaika The other day I changed a file name by loading the .wrangler/state/v3/r2/miniflare-R2BucketObject/X.sqlite into a DB editor. maybe that corrupted something?
I would be doubtful that would break anything but that specific file but you could always just clear out all the local state and try again
@Chaika
@Chaika I deleted my .wrangler and trying to run it but getting "✘ [ERROR] Network connection lost."
How do I set it back up?
I re-did it and it's working