BunnyCDN-API icon indicating copy to clipboard operation
BunnyCDN-API copied to clipboard

Sending large files to stream sotrage

Open Mohamed5550 opened this issue 1 year ago • 0 comments

Hi

I checked BunnyAPI.php file and found at line 100 this code

if ($url_type === 'BASE') {//General CDN
            curl_setopt($curl, CURLOPT_URL, self::API_URL . $url);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: application/json", "AccessKey: $this->api_key", "Content-Type: application/json"));
        } elseif ($url_type === 'STORAGE') {//Storage zone
            curl_setopt($curl, CURLOPT_URL, self::STORAGE_API_URL . $url);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array("AccessKey: $this->access_key"));
        } else {//Video stream
            curl_setopt($curl, CURLOPT_URL, self::VIDEO_STREAM_URL . $url);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array("AccessKey: " . $this->stream_library_access_key, "Content-Type: application/*+json"));
            if ($method === "PUT") {
                curl_setopt($curl, CURLOPT_POSTFIELDS, file_get_contents($params['file']));
            }
        }

As I see it uses file_get_contents to send the file, which stores the file first in memory This can't work with large files

May I ask why don't you make it like storage to use CURLOPT_INFILE?

And thanks for the great package!

Mohamed5550 avatar Oct 19 '24 14:10 Mohamed5550