l0wl3vel/bunny-storage-go-sdk

Implement undocumented DESCRIBE method

Closed this issue · 0 comments

Hyrums law strikes again.

While looking for a way to coerce the list file endpoint to basically head a single file I found an undocumented endpoint to "head" a single file. It is called using the "DESCRIBE" instruction @bene1618 and I stumbled upon while I explained the insanity of using a trailing / to distinguish a List and Download API call using the bunny storage API. We found it by messing around with calling the HEAD method on a file and saw DESCRIBE in the Access Control Header:

HTTP/2 401 
server: nginx
date: Mon, 22 Jan 2024 17:56:09 GMT
content-type: application/json
access-control-allow-headers: AccessKey, Content-Type
access-control-allow-methods: GET, DELETE, POST, PUT, DESCRIBE
access-control-allow-origin: *

Turns out that this allows you to get the Object Metadata for single non-directory files.

curl --request DESCRIBE --url https://storage.bunnycdn.com/myzone/meta/file.txt --header 'AccessKey: secret' --header 'accept: application/json'

This is a very useful function to implement efficient heading of objects in JuiceFS, which is why I think this should be implemented in the library.

It is also used in the official Java SDK: https://github.com/search?q=repo%3ABunnyWay%2FBunnyCDN.PHP.Storage%20describe&type=code