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
Chaika
Chaika2mo ago
--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
Sato
SatoOP2mo ago
This problem persists even when I use --local in all commands. @Chaika
Chaika
Chaika2mo ago
I can't reproduce that if I properly use --local in all commands, ex:
chaik@ash:~/wrangler-test$ cat test.txt
new test
chaik@ash:~/wrangler-test$ npx wrangler r2 object put test/test.txt --file test.txt --local

⛅️ wrangler 3.80.2
-------------------

Creating object "test.txt" in bucket "test".
Upload complete.
chaik@ash:~/wrangler-test$ npx wrangler r2 object get test/test.txt --local --file test2.txt

⛅️ wrangler 3.80.2
-------------------

Downloading "test.txt" from "test".
Download complete.
chaik@ash:~/wrangler-test$ cat test2.txt
new test
chaik@ash:~/wrangler-test$ npx wrangler r2 object delete test/test.txt --local

⛅️ wrangler 3.80.2
-------------------

Deleting object "test.txt" from bucket "test".
Delete complete.
chaik@ash:~/wrangler-test$ npx wrangler r2 object get test/test.txt --local --file test2.txt

⛅️ wrangler 3.80.2
-------------------

Downloading "test.txt" from "test".

✘ [ERROR] The specified key does not exist.
chaik@ash:~/wrangler-test$ cat test.txt
new test
chaik@ash:~/wrangler-test$ npx wrangler r2 object put test/test.txt --file test.txt --local

⛅️ wrangler 3.80.2
-------------------

Creating object "test.txt" in bucket "test".
Upload complete.
chaik@ash:~/wrangler-test$ npx wrangler r2 object get test/test.txt --local --file test2.txt

⛅️ wrangler 3.80.2
-------------------

Downloading "test.txt" from "test".
Download complete.
chaik@ash:~/wrangler-test$ cat test2.txt
new test
chaik@ash:~/wrangler-test$ npx wrangler r2 object delete test/test.txt --local

⛅️ wrangler 3.80.2
-------------------

Deleting object "test.txt" from bucket "test".
Delete complete.
chaik@ash:~/wrangler-test$ npx wrangler r2 object get test/test.txt --local --file test2.txt

⛅️ wrangler 3.80.2
-------------------

Downloading "test.txt" from "test".

✘ [ERROR] The specified key does not exist.
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
Sato
SatoOP2mo ago
@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?
Chaika
Chaika2mo ago
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
Waseem JA
Waseem JA2mo ago
@Chaika
Sato
SatoOP2mo ago
@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
Want results from more Discord servers?
Add your server