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

    albert

    04/22/2022, 5:07 PM
  • a

    albert

    04/22/2022, 5:07 PM
    the "id" field here is the one I used
  • v

    Vitali

    04/22/2022, 5:07 PM
    Yup - the first ID field. Thanks for the screenshot
  • j

    john.spurlock

    04/22/2022, 5:08 PM
    thats what i mean - same as in the PUT call
  • j

    john.spurlock

    04/22/2022, 5:08 PM
    not working : (
  • v

    Vitali

    04/22/2022, 5:10 PM
    and your account ID is for your R2-enabled account?
  • v

    Vitali

    04/22/2022, 5:10 PM
    It's not the same ID
  • j

    john.spurlock

    04/22/2022, 5:10 PM
    yea i'm using the account id in the endpoint, not the access key id
  • j

    john.spurlock

    04/22/2022, 5:10 PM
    i'm able to use r2 from the api, and worker bindings seem to work again too
  • j

    john.spurlock

    04/22/2022, 5:10 PM
    weird
  • j

    john.spurlock

    04/22/2022, 5:11 PM
    auth header is: AWS4-HMAC-SHA256 Credential=/20220422/world/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=
  • m

    mr. matthew breaking changes

    04/22/2022, 5:17 PM
    Endpoint:
    https://{account_id}.r2.cloudflarestorage.com
    Access Key:
    id
    of the API Token Secret Key: sha256sum of the API Token --- Create an API token with the
    Account
    .
    Workers R2 Storage
    .
    Edit
    permission, you can also choose to allow all accounts or just one. After creating the token (you might want to do this in a new tab or copy your api token somewhere safe first), open devtools first then go to the API Tokens list page, find the
    GET tokens?per_page=250
    XHR request and view the response body. Under the
    result
    array find the token you created, and copy the
    id
    (should look like a UUIDv4 without any dashes).
    id
    will be your Access Key. To get the sha256sum of your token, I wrote the token to a new file,
    .tmp
    (in the format
    CLOUDFLARE_API_TOKEN="{api_token}"
    ), ran
    source .tmp
    , then ran
    echo -n "$CLOUDFLARE_API_TOKEN" | sha256sum | cut -f 1 -d " "
    . This will be your Secret Key. (you may also want to also remove
    .tmp
    now and run
    unset CLOUDFLARE_API_TOKEN
    ) For anyone having problems with sha256, make sure that you are not inputting a new line after your token (that's why I used echo with the
    -n
    flag) when passing it to sha256.
  • j

    john.spurlock

    04/22/2022, 5:18 PM
    i had to create a new token! my existing one created earlier works for rest api (to create/delete buckets, push scripts with r2 bindings), but not s3 endpoint
  • j

    john.spurlock

    04/22/2022, 5:20 PM
    thanks all
  • v

    Vitali

    04/22/2022, 5:25 PM
    Oh nice! Glad you found it
  • s

    stupefied | AS204829

    04/22/2022, 5:27 PM
    So, i've never actually utilized an API on a command line before
  • s

    stupefied | AS204829

    04/22/2022, 5:27 PM
    where would I start
  • v

    Vitali

    04/22/2022, 5:27 PM
    Which API?
  • s

    stupefied | AS204829

    04/22/2022, 5:27 PM
    Cloudflare's
  • s

    stupefied | AS204829

    04/22/2022, 5:28 PM
    I want to use it for R2
  • k

    kavinplays

    04/22/2022, 5:28 PM
    if you want to use the rest api, i would start with curl
  • v

    Vitali

    04/22/2022, 5:28 PM
    I know but there's a few APIs
  • v

    Vitali

    04/22/2022, 5:28 PM
    There's APIv4 (which powers the UI but the R2 endpoint is currently undocumented), there's Workers, and S3 compat
  • s

    stupefied | AS204829

    04/22/2022, 5:28 PM
    i have no clue what i'd want to use
  • v

    Vitali

    04/22/2022, 5:28 PM
    What are you trying to do?
  • s

    stupefied | AS204829

    04/22/2022, 5:29 PM
    Create a bucket (R2) and store stuff in it
  • c

    Chaika

    04/22/2022, 5:29 PM
    If you want to just start playing around with/building stuff with R2, take a look at the Sharex r2 example: https://github.com/Cherry/ShareX-R2-Cloudflare-Workers You have to use the Wrangler CLI to create buckets, but storing/etc should just be done with a worker
  • c

    Chaika

    04/22/2022, 5:29 PM
    The R2 Docs have an example too, which details installing and setting up wrangler: https://developers.cloudflare.com/r2/get-started/
  • s

    stupefied | AS204829

    04/22/2022, 5:29 PM
    thanks!
  • s

    stupefied | AS204829

    04/22/2022, 5:32 PM
    nice
1...454647...1050Latest