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

    Karew

    03/15/2023, 9:30 PM
    You want to control cache behavior to reduce the amount of file reads on your bucket. The bucket operations cost money
  • n

    nikitasius

    03/15/2023, 9:31 PM
    ahh type B operations..
  • k

    Karew

    03/15/2023, 9:32 PM
    After setting up a custom R2 domain, it will be behind the Cloudflare CDN/proxy, but you should still tweak Cache Rules to make sure your bucket is cached in the way you want by the CDN
  • o

    omar

    03/15/2023, 9:36 PM
    So, I should basically purchase the CloudFlare CDN service as well ?
  • e

    Erisa | Support Engineer

    03/15/2023, 9:36 PM
    The CDN service is free
  • e

    Erisa | Support Engineer

    03/15/2023, 9:37 PM
    you can add a domain on a free plan and link it
  • o

    omar

    03/15/2023, 9:38 PM
    There are few rules for the free tier, according to what I read from the web. I intend to use my r2 storage to serve images to thousands of people, so I don't think cloudflare will not have any limitations on that regards
  • o

    omar

    03/15/2023, 9:39 PM
    Each user will make around 50 requests per minutes, so that can easily go up to 100k requests to the cdn per minute
  • i

    Isaac McFadyen | YYZ01

    03/15/2023, 9:43 PM
    So... yes, there are. Not on R2 though. Employees have confirmed that the restrictions are not present on R2 (https://canary.discord.com/channels/595317990191398933/940663374377783388/1079063747726950400). There are safe-guards in place that are designed to help prevent abuse on the regular CDN service, and they sometimes are also triggered for R2. In that case you should be able to reach out to support who can help get things sorted out.
  • o

    omar

    03/15/2023, 9:46 PM
    That helps a lot, thanks
  • s

    Sid | R2

    03/15/2023, 11:08 PM
    Data is replicated for redundancy, but not across regions currently, and not in the way you’re describing. You aren’t charged for this replication, per se. The way to get good performance across regions currently is to use the cache. Cache is location-specific, though (that’s just how the cache works). Unfortunately if you are doing lots of reads/writes that need cache busting all the time, it won’t help much (but for that kind of work load, getting low latency across regions becomes a whole new problem that is much more difficult to solve)
  • k

    karimfromjordan

    03/15/2023, 11:08 PM
    I'm experience the same. Setting the content length when generating a presigned url doesn't enforce the content length. I'm still able to upload files that are greater.
  • o

    omar

    03/16/2023, 6:10 AM
    If I am not mistaken, there two types of requests as per S3 spec: - The PUT request that is simpler, but less options - The POST request (as form data) which provides the ability to limit the content type as a range kn a presigned url
  • o

    omar

    03/16/2023, 6:11 AM
    Not sure, if we are allowed to share links in this group
  • f

    Fleetwood

    03/16/2023, 7:34 AM
    My downloads always terminate after x00MB. I think my options are to manually write in JS the ability to fetch byte ranges OR try via the S3 API to see if that's any better
  • k

    karimfromjordan

    03/16/2023, 1:48 PM
    Thanks for this info. I'll try to look it up.
  • o

    omar

    03/16/2023, 1:55 PM
    You can find it by searching for createPresignedPost. The rule you are looking for is a value you add to the condition array like this: - ["content-length-range", 1024, 1024*1024] to restrict the upload to files between 1ko and 1mo
    e
    • 2
    • 5
  • k

    kian

    03/16/2023, 2:09 PM
    Presigned POST is not supported by R2
  • k

    kian

    03/16/2023, 2:09 PM
    You can only presign PUT and specify a specific Content-Length
  • n

    Noodles

    03/16/2023, 4:14 PM
    Just wondering what may be causing this and how I could solve it. So I am storing some MP3 files, but when I go to the URL some display as video players, rather than audio players. This is file specific it seems, as both of these were in the same upload. Example video player: Example correct audio player:
  • e

    Eli

    03/16/2023, 4:34 PM
    Not sure if you saw my example I posted earlier https://discord.com/channels/595317990191398933/940663374377783388/1085517756859940934, but is this the correct way to specify the content length? I have tried it and it seems everything is signing correctly but the URL it gives me just allows whatever to be uploaded of any size/type.
  • k

    karimfromjordan

    03/16/2023, 4:47 PM
    The first doesn't have a Content-Type header but the second one does.
  • k

    karimfromjordan

    03/16/2023, 4:47 PM
    So the content type was probably not set when the first file was uploaded.
  • k

    karimfromjordan

    03/16/2023, 4:48 PM
    Interestingly though, Firefox still uses an audio player for the first file (which it should if the file has an mp3) extension. Just Chrome seems to get it wrong, at least for me.
  • n

    Noodles

    03/16/2023, 6:00 PM
    Strange as these were uploaded through the dashboard at the exact same time so not sure how that got messed up. Hum
  • c

    cake

    03/16/2023, 6:11 PM
    I'm using a worker to grant access to files behind http auth in an r2 bucket. We're getting download failures and it's not clear why... What could I be doing wrong?
    Copy code
    switch (request.method) {
              case 'GET':
                const object = await env.MY_BUCKET.get(key, request.body);
                return new Response(object.body);
  • k

    kian

    03/16/2023, 6:18 PM
    You’re passing a body to get
  • k

    kian

    03/16/2023, 6:18 PM
    That’s not what get wants as a second parameter
  • h

    Harshal

    03/16/2023, 6:36 PM
    👋 Hey everyone just wanted to take a quick sec to announce that Object Lifecycles have been released 🥳 . At the moment we allow configuring rules for deleting objects and aborting uploads by prefix, age or a specific date. You can find some more information on how to use these features in our docs here: https://developers.cloudflare.com/r2/buckets/object-lifecycles/
  • s

    Skye

    03/16/2023, 6:53 PM
    Awesome! You might want to tag the
    @R2
    role to let more people know 🙂
1...945946947...1050Latest