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:
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