0

I'm trying to upload youtube videos to aws S3 bucket. The video is getting uploaded properly but they aren't playing properly. I have written this piece of code:

Tried Code:

$uploadPath = "videouploads/$parsed.mp4";
file_put_contents($uploadPath, file_get_contents($dowloadUrl));
// @formatter:off
$result = $s3->putObject(array(
    'Bucket'     => 'MY_BUCKET',
    'Key'        => 'MY_OBJECT_KEY',
    'SourceFile' => $uploadPath,
));

It will upload the video on my s3 bucket. But when I'm retrieving it using cloudflare the url will be like:

https://media.poweradspy.com/pasvideos/youtube/1w5rtJm8Ujg

Iftikhar uddin
  • 3,117
  • 3
  • 29
  • 48
RAUSHAN KUMAR
  • 5,846
  • 4
  • 34
  • 70
  • _"But when i am retrieving it using cloudfare"_ - How are you retrieving it? How are you getting that URL? Please show us all the relevant code for the issue. Currently, you're just showing us the upload code, which you say works. – M. Eriksson Jan 07 '19 at 07:08
  • @MagnusEriksson We have setup the cloudfare to hide our original video url. So url will be this only – RAUSHAN KUMAR Jan 07 '19 at 07:32

1 Answers1

0

The URL does not give a hint as to the file type (eg .mp4).

Your upload process should store an appropriate content type against the object so the browser knows what type of file it is.

See: amazon web services - Specify Content-Type in AWS PHP's upload function - Stack Overflow

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470