Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //store file input in a varaible
- $file = Input::file('videos');
- //Retrieving The Extension Of An Uploaded File
- $extension = $file->getClientOriginalExtension();
- //define directory to store images
- $directory = '/uploads/videos/';
- $dire = public_path().'/uploads/images';
- //change filename to a random sha1 plus current time
- $filename = "video_" . substr(sha1(time().time()), 0, 15) . mt_rand(5, 10) . ".{$extension}";
- $thumb = "img_" . mt_rand(1, 99999999) . ".png";
- $c = exec("ffmpeg -ss 00:00:05 -i ".$file." -vf 'select=not(mod(n\,1000)),scale=320:240' ".$dire.'/'.$thumb);
- //Move the uploaded file to temp directory
- $s3 = AWS::get('s3');
- $upload_success = $s3->putObject([
- 'ACL' => 'public-read',
- 'Bucket' => 'luzapp',
- 'Key' => $directory.$filename,
- 'Body' => fopen($file->getPathname(), 'r'),
- 'ContentType' => 'video/mp4'
- ]);
- /*upload file to s3 from public folder*/
- $image ='uploads/images/'.$thumb;
- $outputImage = imagecreatefrompng($image);
- // save image in output Buffer --
- ob_start();
- imagejpeg($outputImage,NULL,100);
- $imageFileContents = ob_get_contents();
- // header('Content-Type: image/png');
- // imagepng($imageFileContents);
- // use AwsS3S3Client;
- $directory1 = 'uploads/images/'.$thumb;
- // Create an Amazon S3 client object
- $client = S3Client::factory(array(
- 'secret' => 'C/uZfMI+aAG/oeJ0h/wOFTYohmGCMW/WVL9Bq6E3',
- 'key' => 'AKIAIQH4ZKDFCTMPLOVQ'
- ));
- $context = stream_context_create(array(
- 's3' => array(
- 'ACL' => 'public-read'
- )
- ));
- // Register the stream wrapper from a client object
- $client->registerStreamWrapper();
- $bucket = 'luzapp';
- $key = $directory1;
- // save content on S3 --
- $contents = file_put_contents("s3://{$bucket}/{$key}",$imageFileContents,0,$context);
- $size = filesize("s3://{$bucket}/{$key}");
- ob_end_clean(); // clear o/p buffer
- /*end of upload file to s3 from public folder*/
Add Comment
Please, Sign In to add comment