나는 사람들이 이미이 응답했지만 나는 사람들을 위해 좀 더 컨텍스트를 추가하고 싶다고 참조 보안 된 버킷을 가지고있을 수 있습니다 (액세스 필요). 참고로, S3 버킷에 직접 대화하는 경우 URL을 생성 할 필요가 없으며 'file_get_contents'등을 사용할 수 있습니다. 그러나 속도를 높이기 위해 다중 컬 요청을 사용할 수 없기 때문에 훨씬 느립니다. 그러나 최신 PHP 릴리스가 있으면 pthreads를 사용할 수 있습니다.
설치 : 아마존 용 S3 클래스 파일을 설치하십시오. 작곡가를 사용하여 추가하거나 S3.php 파일을 수동으로 다운로드하는 쉬운 방법이 있습니다.
확보하지 : 가 (당신이 당신의 버킷 보호 한 경우)
http(s)://<bucket>.s3.amazonaws.com/<object>
http(s)://s3.amazonaws.com/<bucket>/<object>
SECURED HTTPS (다만 기본적으로 URL을 사용하여,이 문제에 다른 게시물 참조)
https://amazon.com/file/you/wanted.xxx?ID:XXXXX?SIG:YYYYY
(1) https : // URL을 작성하고 multi curl 도구를 사용하여 동시에 모두 가져올 수 있습니다 (권장).
가장 단순한 예 :
$url = /path/to_the/file_name/file.ext
//note check amazon to confirm the path which will contain only "_" and no spaces.
$s3 = new S3($awsAccessKeyID, $awsSecretKey);
$curls[] = $s3->get_object_url($bucketName, $uri, '1 hour');
var_dump($results = multiCurlRequest($curls));
대한 추가 정보 : 참고로
http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.S3.S3Client.html#_getObjectUrl http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation
:
function multiCurlRequest($curlList = array(),$user = '', $pass = '',$timeout = self::MULTI_REQ_TIMEOUT_SECS, $retTxfr = 1) {
if (empty($curlList) || count($curlList) == 0) return false;
$master = curl_multi_init();
$node_count = count($curlList);
for ($i = 0; $i < $node_count; $i++) {
$ch[$i] = curl_init($curlList[$i]);
curl_setopt($ch[$i], CURLOPT_TIMEOUT, $timeout); // -- timeout after X seconds
curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, $retTxfr);
curl_setopt($ch[$i], CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch[$i], CURLOPT_USERPWD, "{$user}:{$pass}");
curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true);
curl_multi_add_handle($master, $ch[$i]);
}
// -- get all requests at once, finish when done or timeout met --
do { curl_multi_exec($master, $running); }
while ($running > 0);
$results = array();
// -- get results from requests --
for ($i = 0; $i < $node_count; $i++) {
$results[$i] = curl_multi_getcontent($ch[$i]);
if ((int) curl_getinfo($ch[$i], CURLINFO_HTTP_CODE) > 399 || empty($results[$i])) {
$this->set_request( [ ['label' => '404', 'href' => $results[$i], '404' => '1' ] ]);
unset($results[$i]);
}
curl_multi_remove_handle($master, $ch[$i]);
curl_close($ch[$i]);
}
curl_multi_close($master);
if (empty($results)) return false;
//$results = array_values($results); // -- removed as we want the original positions
return $results;
}
의 중복 가능성 [어떻게 PHP로 파일을 다운로드 않으며, Amazon S3 sdk?] (http : // stacko verflow.com/questions/7389394/how-do-i-download-a-file-with-php-and-the-amazon-s3-sdk) –