project-error / npwd

NPWD is a FiveM phone resource written entirely in TypeScript and React.
https://projecterror.dev
Other
336 stars 277 forks source link

feat: adicionado suporte ao r2 #1151

Open HugoSilvaF opened 1 month ago

HugoSilvaF commented 1 month ago

Pull Request Description

I changed config.json, ResourceConfig interface, http-service. I have added supports to Cloudflare R2 to upload images. IMGUR doesnt works anymore, so i have added another option.

To r2 works, need the public link in

image In url needs the public url the r2

"images": {
    "url": "https://pub-your-public-url.r2.dev/",
    "type": "r2",
    "imageEncoding": "jpg",
    "contentType": "multipart/form-data",
    "useContentType": true,
    "authorizationHeader": "Authorization",
    "authorizationPrefix": "Client-ID",
    "useAuthorization": true,
    "returnedDataIndexes": ["data", "link"],
    "r2": {
      "bucketName": "your-bucktname",
      "endpoint" : "https://your-endpoint.r2.cloudflarestorage.com",
      "credentials": {
        "accessKeyId": "your-access-key-id",
        "secretAccessKey": "your-secret-access-key"
      }
    }
  },

your config

image

you need access cloudflare and create an account and a public r2 bucket

https://dash.cloudflare.com/

after created your account you need go to the r2 overiew

image

after this, you need create an bucket

image

after created your bucket go to the settings and get a public url

image

getting a public url

image

Pull Request Checklist:

HugoSilvaF commented 1 month ago

I am waiting the approval.

itschip commented 1 month ago

Hey @HugoSilvaF ! Awesome PR! I'll have a look!

Would be great if you could also update the docs with this guide!