Friday, 10 October 2014

Download Videos from Amazon S3 - PHP

Download Videos from Amazon S3 - PHP

            $newFileName = "download_filename.mp4";
            header('Content-Type: video/mp4');
            header('Content-Disposition: attachment; filename="' . $newFileName . '"');
            $my_aws_key = 'AWS_KEY';
            $my_aws_secret_key = 'AWS_SCRET_KEY';
            $s3 = new Zend_Service_Amazon_S3($my_aws_key, $my_aws_secret_key);
            $newFileName = "S3_download_filename.mp4";
            $response = $s3->getObjectStream("$newFileName");//download stream from s3
            readfile($response->getStreamName());