Hi! I'm looking for some help with my r2

Hi! I'm looking for some help with my r2 bucket. I'm using it via Pages and a binding. I see my put request was successful but I don't see anything in the bucket in the dashboard. I also don't see anything when trying to list all objects via the AWS s3 SDK, but if i get the key in the worker it returns what looks to be the file I uploaded. Any ideas?
4 Replies
_Pear
_PearOP11mo ago
Here you can see the name of the file and the get request returning the file. But why doesn't it show up in the dashboard or my s3 client?
featured_image File {
lastModified: 1708712530425,
name: 'meow_lolsob.png',
type: 'image/png',
size: 5779
}
additional_images
Uploading images...
Image featured_image/meow_lolsob.png already exists in the bucket
GetResult {
range: { offset: 0, length: 5779 },
customMetadata: {},
httpMetadata: {},
uploaded: 2024-02-23T16:43:00.319Z,
checksums: Checksums {
sha512: undefined,
sha384: undefined,
sha256: undefined,
sha1: undefined,
md5: ArrayBuffer {
[Uint8Contents]: <a8 a9 7d 66 09 6b db 36 66 18 68 64 c4 a6 68 48>,
byteLength: 16
}
},
httpEtag: '"a8a97d66096bdb3666186864c4a66848"',
etag: 'a8a97d66096bdb3666186864c4a66848',
size: 5779,
version: 'efad663d0b224d2680489b8c7284aab8',
key: 'images/featured_image/meow_lolsob.png',
bodyUsed: false,
body: ReadableStream {
locked: false,
[state]: 'readable',
[supportsBYOB]: true,
[length]: 5779n
}
}
featured_image File {
lastModified: 1708712530425,
name: 'meow_lolsob.png',
type: 'image/png',
size: 5779
}
additional_images
Uploading images...
Image featured_image/meow_lolsob.png already exists in the bucket
GetResult {
range: { offset: 0, length: 5779 },
customMetadata: {},
httpMetadata: {},
uploaded: 2024-02-23T16:43:00.319Z,
checksums: Checksums {
sha512: undefined,
sha384: undefined,
sha256: undefined,
sha1: undefined,
md5: ArrayBuffer {
[Uint8Contents]: <a8 a9 7d 66 09 6b db 36 66 18 68 64 c4 a6 68 48>,
byteLength: 16
}
},
httpEtag: '"a8a97d66096bdb3666186864c4a66848"',
etag: 'a8a97d66096bdb3666186864c4a66848',
size: 5779,
version: 'efad663d0b224d2680489b8c7284aab8',
key: 'images/featured_image/meow_lolsob.png',
bodyUsed: false,
body: ReadableStream {
locked: false,
[state]: 'readable',
[supportsBYOB]: true,
[length]: 5779n
}
}
@WillTolmie good suggestion, I am awaiting the put. See the logs above, the item IS in the bucket it seems but can I only ever see it from my worker?
WillTolmie
WillTolmie11mo ago
Ah OK so it is there. Have you checked the bucket binding is correct? Could be going into a different bucket
_Pear
_PearOP11mo ago
yeah i looked in both buckets and its missing from both in the dashboard as well as the s3 sdk Oh yeah and it also doesn't show up when trying to use the wrangler r2 object get <path> which is very strange to me!
Downloading "images/featured_image/meow_lolsob.png" from <REDACTED BUCKET NAME>.

[ERROR] The specified key does not exist.
Downloading "images/featured_image/meow_lolsob.png" from <REDACTED BUCKET NAME>.

[ERROR] The specified key does not exist.
My interpretation of the docs is that I need to make the bucket public to see anything in it outside of the worker. I would expect having proper auth would allow me to see the objects tho? yes for the application, which seems to get the object fine. When trying to fetch the individual object I tried wrangler r2 object get, the nodejs aws s3 client list all objects v2 (shows the bucket but nothing in it), and the cloudflare dashboard itself which all show no files at the specified path. are the objects only visible from the binding? In other words, is there is no way to list all objects via the binding without knowing all the key names? Oh yeah that makes sense. Is there is no way to get it to interact w/the remote resources? I saw there is --local as a boolean but setting it to false doesn't seem to do much and --remote doesn't seem to be supported by pages dev And why would I still have Class A/B requests against my bucket if they're not actually being used?
I don't think there is, sorry.
oof bummer, thanks for the info.
Could it be the wrangler commands you're sending?
yeah probs! Seems like this part of the docs is not quite correct then?
Interact with your R2 buckets locally While developing locally, interact with an R2 bucket by adding --r2=<BINDING_NAME> to your run command. For example, if your bucket is bound to BUCKET, access this bucket in local dev by running npx wrangler pages dev <OUTPUT_DIR> --r2=BUCKET. Interact with this binding by using context.env (for example, context.env.BUCKET).
I tried that and it still used the local version of the binding
_Pear
_PearOP11mo ago
Maybe https://github.com/sveltejs/kit/pull/11732 needs to be implemented for it to work locally
GitHub
feat: implement adapter.emulate by Rich-Harris · Pull Request #11...
Breaking this out of #11730, as the changes to adapter-cloudflare and adapter-cloudflare-workers are blocked on the next release of wrangler. Without it, we'll have to make platform.caches opti...
Want results from more Discord servers?
Add your server