[英]AWS S3 via proxy using PHP
我正在嘗試使用PHP通過代理服務器獲取對象圖像。
我正在使用此代碼
$client = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'request.options' => array(
'proxy' => '127.0.0.1:123'
),
'credentials' => [
'key' => base64_decode(KEY),
'secret' => base64_decode(SECRET)
]
]);
這似乎工作正常。 現在,我不確定是否使用代理服務器。
我對此一無所知。
任何想法?
我還沒有在S3Client中使用代理,但是根據我的經驗,任何支持代理的基於PHP或控制台的應用程序都將始終使用代理(如果有說明的話)。 確定您是否使用過代理的最簡單方法是
您還可以使用S3Client的stats
和debug
標志來獲取有關基礎HTTP連接的更多信息,這些信息還應顯示與代理的連接,而不是與AWS的直接連接:
$client = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'debug' => TRUE, // enable debug info
'stats' => TRUE, // enable stats
'request.options' => array(
'proxy' => 'http://127.0.0.1:123' // add the protocol before the IP address
),
'credentials' => [
'key' => base64_decode(KEY),
'secret' => base64_decode(SECRET)
]
]);
// Perform an operation.
$result = $client->listBuckets();
// Inspect the stats.
$stats = $result['@metadata']['transferStats'];
// display all information about last transfer
print_r($stats);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.