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

    Jon @ Transistor

    03/09/2023, 7:18 PM
    for the preflight request?
  • k

    kian

    03/09/2023, 7:21 PM
    If it's not CORS safelisted then you'll need to have
    content-type
    in
    AllowedHeaders
    of your CORS config
  • j

    Jon @ Transistor

    03/09/2023, 7:23 PM
    ah, okay. I'll look at that. yeah, S3 allows for using a wildcard for headers, R2 does not
  • j

    Jon @ Transistor

    03/09/2023, 7:57 PM
    is there a list of headers somewhere that are not safelisted for CORS? preflight is passing now, but the actual upload is a 400 error
    has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource
  • k

    kian

    03/09/2023, 8:01 PM
    https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_request_header
  • k

    kian

    03/09/2023, 8:02 PM
    Not being in the safelist just means you need to add it into
    AllowedHeaders
  • k

    kian

    03/09/2023, 8:02 PM
    The response body on the 400 will tell you why it failed.
  • j

    Jon @ Transistor

    03/09/2023, 8:07 PM
    hmm. it actually has no response body data
  • j

    Jon @ Transistor

    03/09/2023, 11:03 PM
    will keep poking at it, but something is definitely different than S3
  • a

    Angius

    03/09/2023, 11:40 PM
    So, the S3-compatible API docs tell me I need to use
    https://<account_id>.r2.cloudflarestorage.com
    to access my stuff... but the S3 docs for
    ListObjectsV2
    tell me the host is supposed to be
    <bucket>.s3.amazonaws.com
    ... so do I need to use
    https://<bucket>.<account_id>.r2.cloudflarestorage.com
    or...?
  • a

    Angius

    03/09/2023, 11:46 PM
    I guess I'll just yolo it and try this way
  • a

    Angius

    03/09/2023, 11:46 PM
    Cloudflare docs did make me get used to trial and error
  • e

    Erisa | Support Engineer

    03/09/2023, 11:58 PM
    The correct endpoint is
    https://<bucket>.<account_id>.r2.cloudflarestorage.com
    The
    <bucket>.s3.amazonaws.com
    endpoint is for Amazon S3, the AWS product the S3 REST API was originally designed for. R2 is S3-compaptible which means it uses the same API but on its own endpoint and with its own backing data store Aside from endpoint the functionality is the same for both, so the S3 docs can be used provided the endpoint is swapped out for the service being used
  • a

    Angius

    03/09/2023, 11:59 PM
    Gotcha, I was simply wondering where to put the bucket ID, thanks!
  • e

    Erisa | Support Engineer

    03/09/2023, 11:59 PM
    R2 has bucket names scoped to accounts so it has the account ID in there too
  • a

    Angius

    03/10/2023, 12:21 AM
    Another issue reared it's ugly head...
    Copy code
    > esbuild build.ts --outfile=build.mjs && node build.mjs
    
    
      build.mjs  1.4kb
    
    ⚡ Done in 8ms     
    node:internal/deps/undici/undici:11413
        Error.captureStackTrace(err, this);
              ^
    
    TypeError: fetch failed
        at Object.fetch (node:internal/deps/undici/undici:11413:11)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async file:///G:/WebstormProjects/work/technikum/build.mjs:25:16 {
      cause: [Error: DC450100:error:0A000410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:c:\ws\deps\openssl\openssl\ssl\record\rec_layer_s3.c:1605:SSL alert number 40
      ] {
        library: 'SSL routines',
        reason: 'sslv3 alert handshake failure',
        code: 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE'
      }
    }
    
    Node.js v19.7.0
     ELIFECYCLE  Command failed with exit code 1.
    
    Process finished with exit code 1
    Trying to
    fetch()
    from that URL throws some weird SSLv3 error. I tried using the
    --tls-min-v1.x
    param when running
    node
    , but whether that
    x
    was 0, 1, 2, or 3, made no difference.
  • a

    Angius

    03/10/2023, 12:31 AM
    I'll just... save the list of file names to a file and use that
  • a

    Angius

    03/10/2023, 12:45 AM
    Ah, well, seems accessing the files doesn't work either... I have it a custom domain enabled (
    cdn-mystuff.me.info
    ) for the bucket,
    https://mystuff.me.info
    is added to the CORS settings of the bucket, and yet
    Copy code
    html
    <audio src="https://cdn-mystuff.me.info/my-bucket/my-file.mp3"></audio>
    results in the file 404ing
  • k

    kian

    03/10/2023, 12:54 AM
    Unless you have a folder in the bucket called
    my-bucket
    ,
    /my-bucket
    shouldn't be there
  • a

    Angius

    03/10/2023, 12:56 AM
    Ah, duh, of course
  • a

    Angius

    03/10/2023, 12:57 AM
    I forgot that the domain is set up per-bucket... Me getting used to B2 is showing lol
  • a

    Angius

    03/10/2023, 12:57 AM
    Thanks!
  • s

    Sid | R2

    03/10/2023, 1:18 AM
    Today! In fact ListParts is implemented for the S3 API now.
  • p

    pedrocx486

    03/10/2023, 3:39 AM
    Hey lads, how are you doing? Sorry if I'm being exceedingly dumb, but my Google Fu has failed me and Discord's search didn't wield anything :/ I'm having a "problem" that is, I have an PNG file (this one:

    https://cdn.pedrocx486.club/test3.png▾

    ) that is 38MB in size (a render output straight from Blender) that R2 refuses to serve. I uploaded smaller files and was able to load them no issue with the direct URL. Am I doing something wrong or R2 doesn't support serving "large" files like this? Cheers
  • j

    Jacob | Pages

    03/10/2023, 3:50 AM
    Does the image display if you open it in browser locally? I’m able to download the file fine, but it won’t display as an image
  • j

    Jacob | Pages

    03/10/2023, 3:51 AM
  • p

    pedrocx486

    03/10/2023, 3:51 AM
    Yep
  • p

    pedrocx486

    03/10/2023, 3:52 AM
    Any chance aws-cli could've got the file corrupted?
  • p

    pedrocx486

    03/10/2023, 3:52 AM
    I'll upload another using the web interface
  • p

    pedrocx486

    03/10/2023, 3:53 AM
    Ah, crap. With the web interface it works.

    https://cdn.pedrocx486.club/test2.png▾

1...938939940...1050Latest