How do i work with an API(r2 Bucket)
i realise the question sounds really dumb but like whats the url and stuff im meant to use to let my code access my bucket š , im kinda new to coding and stuff in general so i realise im skipping steps but ireally wanna learn how to do this, any and all help is appreciated, ive looked at documentation and stuff and even went so far as to ask chat gpt to tell š, but idk what to do, or how to work w one at all and i literally have no clue how to do anything
19 Replies
i might not respond instantly when someone replies here as im making this before going to school
and im using the bucket to store stuff for a bot
Hey! Let's break this into steps.
1. Can you let me know how are you building your application? Are you using Workers to build the bot?
2. If you want to do Upload/Download via an API - check the S3 API docs (https://developers.cloudflare.com/r2/api/s3/api/). This would be a good place to start
back from school
so
so
im not using workers for this
because
i didnt know what workers were when i started this project
if im beign fr
i started this project
saturday 1 am
so
or friday night 1 am
depending on how you look at time
so its only been a couple days
of this
ill put my code here so i can get feedback
ive look at the s3 api docs
this is my last resort
ive spent hours reading through them
but i wouldnt be surprised if i missed something
the comments are different ways i tried things
im tryna get zone id rn
it should be under my account id
but it isnt
so idk
i have no clue waht to do
or how to do it
to get my ccode to access my image bucket
ive been stuck on this
for so long its not even funny
(all of yesterday
its a url error
because it always outputs a error 400
like
with every url ive tried
i havent tried zone id becayse i cant find mine
wait
im so dumb
omg
api token
not gloval key
i see
im sorry for opening this
ill close it if this works
this is sad
idk what t o do ig
@Harshil Agrawal im sorry for @ing you but um
do you have any idea what t o do
You are not using the correct URL. The docs that I linked specify the URL for R2.
https://<ACCOUNT_ID>.r2.cloudflarestorage.com
that one?
augh
ill look after eating
ba
c
is it bc bearer is in there?
no
the url i used was found in the link you sent
oh
a diff part of the doc
im so confused
š
sorry
the url u gave me
gives me a bad url error
url i found gives me a perms error
so i feel like im making progress
idk
um
it kind a works
no moreerror messages
but it still sayas undefined
when i ask it to like
tell me the res
okay so data does have stuff in its results
wait wrong chat
I guess it is working š
kinda?
i decided to change how i do things
as in
that gives me everything
which isnt what i want
i wanna be able to pick and choose between species
i was trying to do things like this
but ofc cloudflare doesnt haev directories
so now im trying to make the path inside my code
and then ask it to fetch that path and only that path
im struggling tho becuase
how to construct url properly fr
gonna go check more docs ig
OH
presigned urls
i think
no
Object storage doesn't have a directory structure. You can have files with name
folder1/folder2/file.png
. On the R2 dashboard you can view them as directories, however, they don't function as directories. The file just gets named like that