need to upload video on cloudflare stream using laravel

Hi need to upload video on cloudflare stream using laravel My laravel code is: public function handle() { try { $authToken = env('AUTH_TOKEN_STREAM') $apiEndpoint = env('API_ENDPOINT_STREAM') $workouts = public_path('images/video.mp4'); $videoContents = fopen($workouts, 'rb'); //$videoContents = file_get_contents($workouts); if ($videoContents !== false) { echo "Uploading video: " . $workouts . "\n"; $response = Http::withHeaders([ 'Authorization' => 'Bearer ' . $authToken, ])->attach('file', $videoContents, basename('video.mp4')) ->post($apiEndpoint); print_r($response); if ($response->successful()) { print_r('=============================='); print_r($response->json()['result']['id']); echo "\n"; } } $this->info('Images Uploaded on Cloudflare'); } catch (\Exception $e) { print_r('Its in Catch Block'); echo "\n"; print_r('===================================='); $this->handle(); } }
1 Reply
zegevlier
zegevlier15mo ago
Please don't post the same question in two different channels. This fits better in #general-help, so I'm closing this one.
Want results from more Discord servers?
Add your server