https://discord.cloudflare.com logo
Join Discord
Powered by
# r2
  • s

    Sid | R2

    05/16/2023, 7:13 PM
    rclone in a git hook maybe?
  • g

    George Boot

    05/16/2023, 8:26 PM
    Why a pain? We do a similar things and don’t experience it as a pain at all
  • w

    Waldo

    05/16/2023, 8:32 PM
    For some reason we find it hard to setup and debug. We made a solution that uses repo webhooks to POST to a worker, but the approach feels somewhat hacky.
  • s

    Siclude

    05/16/2023, 8:50 PM
    I want to be able to share R2 admin UI with my teammates. How do I give them access? For clarity, I want to take this view and give my other teammates access to the same view that I see. I am asking in here about R2 but more generally, I would like to give them access to all the other services also. Thanks

    https://cdn.discordapp.com/attachments/940663374377783388/1108134440175161364/image.png▾

  • If you go to the manage account button
    s

    Skye

    05/16/2023, 8:52 PM
    If you go to the manage account button at the bottom of the sidebar there, there should be a members tab where you can invite others
    s
    • 2
    • 11
  • f

    Fake User

    05/17/2023, 5:44 AM
    Hey Yall I'm having a bit of trouble uploading to r2 I'm trying to put an object in a bucket with deno & the *aws-sdk/client-s3 * package But when I put something in the Body: , nothing will upload here is the .js file when there is nothing in the Body: , it will upload just fine but if there is anything in the Body: , nothing will upload at all
    Copy code
    js
    /* ---------- ⛅ UPLOAD TO CLOUDFLARE R2 ⛅ ---------- */
    import{S3Client, PutObjectCommand} from "npm:@aws-sdk/client-s3";
    import{load} from "https://deno.land/std/dotenv/mod.ts";
    const env = await load();
    
    //setup r2
    const r2 = new S3Client({
        region: env["R2_REGION"],
        endpoint: env["R2_ENDPOINT"],
        credentials: {
            accessKeyId: env["R2_KEY"],
            secretAccessKey: env["R2_SECRETKEY"]
        }
    });
    
    //this object will upload
    let objectWillUpload = {
        Bucket: env["R2_BUCKET"],
        Key: "this-will-upload",
        Body: ""
    };
    r2.send(new PutObjectCommand(objectWillUpload));
    
    //this object will not upload
    let objectWillNotUpload = {
        Bucket: env["R2_BUCKET"],
        Key: "this-will-not-upload",
        Body: "this really will not upload"
    };
    r2.send(new PutObjectCommand(objectWillNotUpload));
  • b

    bret

    05/17/2023, 12:29 PM
    Potentially dumb questions so apologies in advance. I used to use Blackblaze's ObjSto product with Cloudflare over the top, though I'm now interested in using R2 instead. I'll be using it to store and serve 300MB-5GB files. I understand on the free plan there is a limit for caching of 512MB, however in terms of serving the files, let's say I have my bucket in Western Europe and a user downloads from California, or Beijing, will it be served from Western Europe to both of them, or will it be routed through a local PoP?
  • h

    HardAtWork

    05/17/2023, 12:40 PM
    It would be routed through the local pop first, but then fetched from Western Europe. Note too that using pops in China requires a special license
  • b

    bret

    05/17/2023, 12:41 PM
    Ah! Yes, that (RE: licensing) makes sense. In theory then, it would route through whichever is closest and still provide a benefit over serving everything from Western Europe directly, however marginal. Maybe I'll need to do some testing and see
  • d

    divby0

    05/17/2023, 1:25 PM
    I looked into the docs but couldn't find any infos on my question: I am creating a multi-tenancy webapp where each user or organization can upload images. Since there aren't real folders, is there a kind of prefix I should use to group files that belong to the same owner? (Thinking about making them easier to delete in bulk later or faster queries when looking for a specific file) - or doesn't it matter at all and I should just choose arbitrary uids for each upload and link them in my database?
  • k

    Karew

    05/17/2023, 1:34 PM
    For an app like this, I would keep a reference to all files in your database regardless. But yes, for choosing a key, a prefix that involves their account ID or something to section them off from each other could work
  • h

    HardAtWork

    05/17/2023, 1:35 PM
    While you can’t delete a folder in a single op, you can list on a prefix/folder, so grouping each user/org into their own prefix means you don’t need a DB call to delete everything belonging to said user/org
  • d

    divby0

    05/17/2023, 1:40 PM
    I think I should definitely keep a reference to all the files in my db, that's probably true. Apart from that, how are "folders/prefixes" seperated? By a "/"?
  • h

    HardAtWork

    05/17/2023, 1:50 PM
    Yes
  • s

    Siclude

    05/17/2023, 5:56 PM
    Hi all, tried searching before asking but no luck. I am using the example provided here (https://developers.cloudflare.com/r2/examples/aws/aws-sdk-js-v3/) and my CORS policy on my R2 bucket looks like this: [ { "AllowedOrigins": [ "http://localhost:3000", "http://localhost:5173" ], "AllowedMethods": [ "GET", "PUT", "POST" ] } ] However, when I try to access it from localhost:5173, I am getting this error: Access to fetch at 'https://ACCOUNT_ID.r2.cloudflarestorage.com/' from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
  • s

    Sid | R2

    05/17/2023, 9:16 PM
    I don’t see anything obviously wrong with this, do you see an error when the upload fails?
  • s

    Sid | R2

    05/17/2023, 9:16 PM
    I’m not near my laptop right now so can’t confirm, but I think your issue might be the trailing slashes in your Origins. Have you tried removing them?
  • s

    Sid | R2

    05/17/2023, 9:18 PM
    Another common issue is extra headers. If you’re sending any additional headers with your request, you’ll want to make sure you include them in the AllowedHeaders key
  • s

    Siclude

    05/17/2023, 9:24 PM
    I'm just using the code from the example and using the sdk so... Whatever is in the sdk. Not sending it myself.
  • f

    Fake User

    05/17/2023, 9:31 PM
    @Sid | R2 there aren't any errors there actually isn't anything in the console it will just hang for a sec, but the first object succesfully uploads
  • f

    Fake User

    05/17/2023, 9:32 PM

    https://cdn.discordapp.com/attachments/940663374377783388/1108507279751389246/run.png▾

  • f

    Fake User

    05/17/2023, 9:32 PM

    https://cdn.discordapp.com/attachments/940663374377783388/1108507357236969633/upload.png▾

  • f

    Fake User

    05/17/2023, 9:34 PM
    could you point out the trailing slashes you're talking about? also, thanks for replying & helping out thats super cool
  • s

    Sid | R2

    05/17/2023, 9:41 PM
    Oh wait a sec, don’t you have to await your upload promises? I think when there’s a body, your Deno function or whatever is likely canceling the promise before the upload finishes. The trailing slash thing doesn’t relate to you, I was replying to a different message.
  • s

    Sid | R2

    05/17/2023, 9:43 PM
    Oh, I was talking about your CORS policy. Try removing the trailing slashes from the origins in your AllowedOrigins key.
  • f

    Fake User

    05/17/2023, 9:46 PM
    ah haa, that does give an error
  • f

    Fake User

    05/17/2023, 9:46 PM

    https://cdn.discordapp.com/attachments/940663374377783388/1108510861049471126/await.png▾

  • Deno Promises
    f

    Fake User

    05/17/2023, 9:46 PM

    https://cdn.discordapp.com/attachments/940663374377783388/1108510890510274560/sc.png▾

    s
    • 2
    • 3
  • f

    flayks

    05/17/2023, 10:04 PM
    I'm not totally aware of what's doable with R2 but would it be possible to host small video files on it and cache it under a CDN for fast delivery?
  • s

    Sid | R2

    05/17/2023, 10:08 PM
    Yep! If it’s just videos you want to stream, you may also want to look into the Stream product, which has a bunch of neat features for, well, streaming
1...103110321033...1050Latest