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

    haltbill

    04/07/2023, 6:31 AM
    idk what is going wrong
  • CredentialsProviderError: Could not load credentials from any providers
    k

    Kuyumee

    04/07/2023, 8:04 AM
    I'm trying to upload a test image. It works fine before I convert it to v3, but when I use
    npx aws-sdk-js-codemod -t v2-to-v3 index.js
    , it stops working. v2:
    Copy code
    js
    require("dotenv").config();
    const AWS = require("aws-sdk");
    const fs = require("fs");
    
    const s3 = new AWS.S3({
      endpoint: process.env.R2_ENDPOINT,
      accessKeyId: process.env.R2_ACCESS_KEY,
      secretAccessKey: process.env.R2_SECRET_KEY,
      region: process.env.R2_REGION,
    });
    
    (async () => {
      const result = await s3
        .upload({
          Bucket: process.env.R2_BUCKET_NAME,
          Key: "IMG20221229195709.jpg",
          Body: fs.createReadStream("IMG20221229195709.jpg"),
        })
        .promise();
      console.log(`File uploaded successfully. ${result.Location}`);
    })();
    v3 (not working):
    Copy code
    js
    require("dotenv").config();
    const { Upload } = require("@aws-sdk/lib-storage");
    const { S3 } = require("@aws-sdk/client-s3");
    const fs = require("fs");
    
    const s3 = new S3({
      endpoint: process.env.R2_ENDPOINT,
      accessKeyId: process.env.R2_ACCESS_KEY,
      secretAccessKey: process.env.R2_SECRET_KEY,
      region: process.env.R2_REGION,
    });
    
    (async () => {
      const result = await new Upload({
        client: s3,
    
        params: {
          Bucket: process.env.R2_BUCKET_NAME,
          Key: "IMG20221229195709.jpg",
          Body: fs.createReadStream("IMG20221229195709.jpg"),
        },
      }).done();
      console.log(`File uploaded successfully. ${result.Location}`);
    })();
    e
    • 2
    • 4
  • w

    Walshy | Pages

    04/07/2023, 1:29 PM
    Hey y'all Be aware we're seeing an elevated error rate in Dublin for R2 https://www.cloudflarestatus.com/incidents/w7pct40l2210 edit: This is resolved
  • t

    Timothy

    04/07/2023, 9:38 PM
    wish I had gotten an email when r2.dev rate limits were added. only found out even that production workloads aren't intended when I started getting reports from users and came to grep this channel (that info wasn't in the dashboard when I set up r2). never got alerts that we were exceeding the limit either because I don't log into the dashboard much :/
  • k

    Karew

    04/07/2023, 10:09 PM
    I am currently still uncertain why r2.dev exists at all, frankly. Because you can’t set up any Cloudflare tools in front of it, it’s not even really that useful for development or testing? You can create a bucket-dev.example.com subdomain or something for your project instead.
  • t

    Timothy

    04/07/2023, 10:11 PM
    I didn't really want any cloudflare tools in front -- just need a URL I can serve files from for my app, it doesn't have to be pretty. I do use a redirection shim for the prettier URLs (so I'm not hardcoding r2 urls in my app) but it's on aws. can't transfer the second-level domain to cloudflare, so now to set up the custom domain I had to buy a separate cdn domain
  • k

    Karew

    04/07/2023, 10:15 PM
    Right, but r2.dev doesn’t allow for that, specifically because of the rate limits. Because it has both the limits + no Cloudflare proxy tools you can adjust, I don’t know why it’s offered.
  • u

    Unsmart | Tech debt

    04/07/2023, 10:17 PM
    Its there for testing can be nice when doing stuff within the dashboard
  • k

    Karew

    04/07/2023, 10:19 PM
    What can you test? That an object is being served by the bucket? For example, if I want to eventually put a bucket into production, I can’t test any other things like Cache Rules in front of r2.dev or rewrites, redirects, etc
  • h

    HardAtWork

    04/07/2023, 10:25 PM
    It’s also there if you don’t own a domain. Some people can’t/won’t buy a domain, so this is an easy way to at least host small amounts of files
  • r

    Ryuntai

    04/07/2023, 11:46 PM
    the income and outgoing traffic will be cache correct?
  • d

    DJPaul

    04/07/2023, 11:48 PM
    Any news on when bucket-scoped tokens might be available?
  • s

    Skye

    04/07/2023, 11:51 PM
    I saw a tweet saying by the End of Quarter is a goal
  • s

    Skye

    04/07/2023, 11:51 PM
    Can't seem to find it now
  • u

    Unsmart | Tech debt

    04/07/2023, 11:59 PM
    https://twitter.com/dok2001/status/1644334830744731649?t=c3HJ376oI5_CrS-74K9Arg&s=19
  • s

    Skye

    04/08/2023, 12:00 AM
    that's it
  • l

    landscapepainter

    04/08/2023, 2:18 AM
    Hi everyone, is there a naming rule for r2 bucket names besides
    Bucket name can only contain lowercase letters (a-z), numbers (0-9), and hyphens (-)
    ? I was wondering if r2 follows exactly the same naming rules as s3(https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html) or has some different set of rules. Also, is there a doc for r2 naming rules?
  • r

    Ryuntai

    04/08/2023, 3:50 AM
    How do i use caching with R2? do i have to create a page rule and set the cache level to bypass?
  • k

    kian

    04/08/2023, 3:56 AM
    Bypass would be the opposite, as it wouldn't cache.
  • k

    kian

    04/08/2023, 3:56 AM
    It'll cache most file extensions by default
  • r

    Ryuntai

    04/08/2023, 3:58 AM
    my bad.
  • r

    Ryuntai

    04/08/2023, 4:00 AM
    I will just set cache to " Cache everything " since cloudflare does not read my files extension.
  • r

    Ryuntai

    04/08/2023, 4:00 AM
  • m

    Migmac

    04/08/2023, 12:27 PM
    Hi! I am trying to setup an upload mechanism for R2 I have gotten it to work through postman, and getting a pre-signed url is also working properly. However, when doing it in the browser, I get the
    Copy code
    Access to XMLHttpRequest at _____ from origin 'http://localhost:5174' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
    Should mention the preflight also returns the proper headers I have setup the bucket CORS settings to include for the
    Copy code
    http://localhost:5174
    origin, as well as the
    Copy code
    PUT
    and have set the Allowed Headers to
    Copy code
    *
    and also tried with
    Copy code
    Content-Type
    Any suggestions as to why this isn't working and a possible way to fix it?
  • m

    Migmac

    04/08/2023, 12:30 PM
    Just figured it out. Was sending out a POST request instead of a PUT and POST are not supported .-.
  • s

    SKRRRTT

    04/09/2023, 3:12 AM
    In the event of someone spamming your requests because they are purposely trying to charge you money, how would that be handled?
  • s

    SKRRRTT

    04/09/2023, 3:15 AM
    ping me when you respond
  • k

    kian

    04/09/2023, 3:25 AM
    Billing may or may not reduce or refund the usage but that's always a good will gesture that's up to them.
  • k

    kian

    04/09/2023, 3:25 AM
    You'd be expected to use caching, rate limiting, WAF, etc - to mitigate attacks yourself
  • s

    SKRRRTT

    04/09/2023, 3:26 AM
    so if I'm using all of that, and I still get charged a lot from spam there's a good chance they would reduce it?
1...980981982...1050Latest