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
14 Replies
dragon
dragonā€¢2d ago
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
harshil1712
harshil1712ā€¢23h ago
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
dragon
dragonā€¢18h ago
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
dragon
dragonā€¢18h ago
No description
dragon
dragonā€¢18h ago
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
dragon
dragonā€¢18h ago
No description
dragon
dragonā€¢18h ago
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
harshil1712
harshil1712ā€¢18h ago
You are not using the correct URL. The docs that I linked specify the URL for R2.
dragon
dragonā€¢17h ago
https://<ACCOUNT_ID>.r2.cloudflarestorage.com that one? augh ill look after eating ba c
dragon
dragonā€¢17h ago
No description
dragon
dragonā€¢17h ago
No description
dragon
dragonā€¢16h ago
const {accountId} = require('./config.json');
const {apiKey} = require('./config.json');
const bucket = 'shark'
fetch(`https://${accountId}.r2.cloudflarestorage.com`, {
method: 'GET',
headers : {
Authorization : `Bearer ${apiKey}`,
'Content-Type' : "application/json"
}}).then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
});
const {accountId} = require('./config.json');
const {apiKey} = require('./config.json');
const bucket = 'shark'
fetch(`https://${accountId}.r2.cloudflarestorage.com`, {
method: 'GET',
headers : {
Authorization : `Bearer ${apiKey}`,
'Content-Type' : "application/json"
}}).then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
});
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
dragon
dragonā€¢14h ago
okay so data does have stuff in its results
No description
dragon
dragonā€¢14h ago
wait wrong chat
Want results from more Discord servers?
Add your server