env('BUNNY_STORAGE_API_KEY'), 'Accept' => 'application/json', 'Content-Type' => 'application/octet-stream' ]; $fileStream = fopen($file, "r"); $file = fread($fileStream, filesize($file)); return PendingRequest::baseUrl('https://storage.bunnycdn.com')->withHeaders($headers)->withBody($file)->throw(); }); PendingRequest::macro('purge', function ($url) { $headers = [ 'AccessKey' => env('BUNNY_API_KEY'), 'Accept' => 'application/json', ]; return PendingRequest::withHeaders($headers)->post('https://api.bunny.net/purge', [ "urls" => [$url], ])->throw(); }); try { Http::pool(fn (Pool $pool) => [ $pool->storage(file: "$parent_dir/$compose_file")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file"), $pool->storage(file: "$parent_dir/$compose_file_prod")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$compose_file_prod"), $pool->storage(file: "$parent_dir/$production_env")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$production_env"), $pool->storage(file: "$parent_dir/scripts/$upgrade_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$upgrade_script"), $pool->storage(file: "$parent_dir/scripts/$install_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$install_script"), $pool->storage(file: "$parent_dir/scripts/$docker_install_script")->put("/$bunny_cdn_storage_name/$bunny_cdn_path/$docker_install_script"), $pool->storage(file: "$parent_dir/$versions")->put("/$bunny_cdn_storage_name/$versions"), ]); Http::withHeaders([ 'AccessKey' => env('BUNNY_API_KEY'), 'Accept' => 'application/json', ])->get('https://api.bunny.net/purge', [ "url" => "$bunny_cdn/$bunny_cdn_path/*", "async" => false ])->throw(); echo "All files uploaded & purged...\n"; } catch (\Exception $e) { echo $e->getMessage(); } } }