Like all great services Bunny CDN has an API. Making use theoretically easier. The storage API allows you to upload files, delete files and list files/directories. I’m interested in the listing of files in the storage zone. With the API I can check files have already been uploaded, their size, format and even the date/time they got uploaded.
The default Bunny CDN API returns the uploaded (created) time in ISO 8601 time format, which isn’t compatible with PHP date and time functions. Also returned is the file size as raw bytes not quite as handy to having it in formatted MB and GB.
I addressed these issues in this PHP file. Thanks to a format size units function i got off stack overflow I made a simple function to remove the unnecessary data returned from the API and format it so you can see the simple file name and its extension. Converting the ISO 8601 time stamp into a PHP compatible one makes sorting by upload date easy.