, , , ( ). : URL-, S3, "file_get_contents" .., , ( ). pthreads, php.
:
S3 Amazon, S3.php .
:
(. , URL-)
http(s)://<bucket>.s3.amazonaws.com/<object>
http(s)://s3.amazonaws.com/<bucket>/<object>
HTTPS ( ):
https:
(1) Create https: // url and use the multi curl tool to get them all at the same time (recommended).
The simplest example:
$url = /path/to_the/file_name/file.ext
$s3 = new S3($awsAccessKeyID, $awsSecretKey);
$curls[] = $s3->get_object_url($bucketName, $uri, '1 hour');
var_dump($results = multiCurlRequest($curls));
Additional Information:
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
FYI:
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);
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]);
}
do { curl_multi_exec($master, $running); }
while ($running > 0);
$results = array();
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;
return $results;
}