代码点火器和S3
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了代码点火器和S3相关的知识,希望对你有一定的参考价值。
public function batchUploadS3($files, $bucket, $bucketPath = '') { // Now we should push these off to S3 // Include the SDK $s3 = new AmazonS3(); // Prepare to hold the individual filenames // Loop over the list, referring to a single file at a time foreach ($files as $id=>$file) { // Grab only the filename part of the path $filename = $bucketPath.'/'.$fileParts['basename']; // Store the filename for later use $individual_filenames[$id] = $filename; /* Prepare to upload the file to our new S3 bucket. Add this request to a queue that we won't execute quite yet. */ 'fileUpload' => $file, 'acl' => AmazonS3::ACL_PUBLIC )); } /* Execute our queue of batched requests. This may take a few seconds to a few minutes depending on the size of the files and how fast your upload speeds are. */ $file_upload_response = $s3->batch()->send(); /* Since a batch of requests will return multiple responses, let's make sure they ALL came back successfully using `areOK()` (singular responses use `isOK()`). */ if ($file_upload_response->areOK()) { // Loop through the individual filenames foreach ($individual_filenames as $id=>$filename) { /* Display a URL for each of the files we uploaded. Since uploads default to private (you can choose to override this setting when uploading), we'll pre-authenticate the file URL for the next 5 minutes. */ $files[$id] = $s3->get_object_url($bucket, $filename); } }else{ } return $files; }
以上是关于代码点火器和S3的主要内容,如果未能解决你的问题,请参考以下文章