flydrive-js / core

File Storage abstraction for cloud services and local filesystem
https://flydrive.dev
MIT License
66 stars 1 forks source link

BucketName in CDN URL #2

Closed shiny closed 4 weeks ago

shiny commented 1 month ago

According to the Flydrive document, the default CDN URL should be composed of cdnUrl + filename

const disk = new Disk(
  new S3Driver({
    cdnUrl: 'https://assets.myapp.com',
    endpoint: 'https://jg21.r2.cloudflarestorage.com',
    bucket: 'testing-drive',
  })
)

const URL = await disk.getUrl('avatar.png')
console.log(URL) // https://assets.myapp.com/avatar.png

But actually the result is cdnUrl + bucket + filename https://github.com/flydrive-js/core/blob/85628e9daf476389e98a55ea8611f7ec7e78dc4e/drivers/s3/driver.ts#L406

shiny commented 1 month ago

In cloudflare R2, bucket is not a part of public URL. for a temporary fix, we can specify a urlBuilder callback for the correct format.

thetutlage commented 4 weeks ago

Fixed in https://github.com/flydrive-js/core/commit/11ab6ce27b02d0b5f34f212a2893c2ab9e8ef0fe

thetutlage commented 4 weeks ago

Fixed in https://github.com/flydrive-js/core/releases/tag/v1.0.3