我正在尝试通过Laravel 4将文件上传到Amazon S3.
用户提交表单后,该文件将传递给我需要使用Amazon PHP SDK并将文件上传到Amazon S3存储桶的函数.
但是如何在不将文件保存到服务器的情况下直接将文件上传到Amazon S3.
我目前的代码是这样的,
private function uploadVideo($vid){
$file = $vid;
$filename = $file->getClientOriginalName();
if (!class_exists('S3'))require_once('S3.php');
if (!defined('awsAccessKey')) define('awsAccessKey', '123123123');
if (!defined('awsSecretKey')) define('awsSecretKey', '123123123');
$s3 = new S3(awsAccessKey, awsSecretKey);
$s3->putBucket("mybucket", S3::ACL_PUBLIC_READ);
$s3->putObject($vid, "mybucket",$filename , S3::ACL_PUBLIC_READ);
}
Run Code Online (Sandbox Code Playgroud)