尝试将文件上传到php中的s3存储桶。
我正在将视频.mp4大小(1 mb)上传到mybucket / temp文件夹并从该视频中剪切拇指文件(临时文件夹仅在s3存储桶中)。
那是我的代码: -
$video_type = strtolower(pathinfo($video_name, PATHINFO_EXTENSION));
//Create object S3 ,File path models/S3.php
$object_s3 = new S3(Yii::$app->params['aws_access_key'], Yii::$app->params['aws_secret_key']);
//bucket name
$Amazon_Bucket = "abc-videos";
//create image name dynamically and unique
$uploadimage = $insert_videoid . "-thumb.jpg";
//create video name dynamically and unique
$uploadvideo = $insert_videoid . "-video." . $video_type;
exec("ffmpeg -i " . $videotempname . " -deinterlace -an -ss 00:00:05 -t 00:00:01 -s 150x150 -r 1 -y -vcodec mjpeg -f mjpeg " . $uploadimage . " 2>&1");
$thumbfile = $insert_videoid . "/thumb-" . $insert_videoid . ".jpg";
if ($object_s3->putObjectFile($videotempname, $Amazon_Bucket, $uploadvideo, S3::ACL_PUBLIC_READ)) {
//create url and update in tbl_video
$object_s3->putObjectFile($uploadimage, $Amazon_Bucket, $thumbfile, S3::ACL_PUBLIC_READ);
$url = "http://" . $abc . ".s3.amazonaws.com/" . $uploadvideo;