【发布时间】:2016-12-02 15:12:47
【问题描述】:
我们正在尝试使用 PHP 库 (https://github.com/softlayer/softlayer-object-storage-php) 将文件上传到对象存储并收到 408 请求超时错误。
请求超时
服务器等待客户端发送请求的时间过长。
当我们上传大小约为 1MB 的文件时会发生这种情况。
require_once('libs/softlayer/ObjectStorage/Util.php');
$tokenStore = ObjectStorage_TokenStore::factory('file', array('ttl' => 3600, 'path' => '/tmp'));
ObjectStorage::setTokenStore($tokenStore);
$options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);
$host = 'https://sng01.objectstorage.softlayer.net/auth/v1.0/';
$username = 'xxxxxx';
$password = 'xxxxxx';
$objectStorage = new ObjectStorage($host, $username, $password, $options);
$container = 'xxxx/';
$files = ['/tmp/objectstorage_test/sample_617K.zip', '/tmp/objectstorage_test/sample_1_3M.zip'];
foreach($files as $file){
print_r("Uploading $file ...");
try{
$filename = basename($file);
$url = $container . $filename;
$content_type = 'application/octet-stream';
$rst = $objectStorage->with($this->container.$url)
->setLocalFile($file)
->setHeader('Content-type', $content_type)
->create();
print_r($rst);
print_r("Successfully uploading $file");
}catch(Exception $e){
print_r($e->getMessage());
}
}
我尝试上传了 2 个文件,第一个文件 (sample_617K.zip) 已成功上传。第二个文件 (sample_1_3M.zip) 在 5 分钟后返回错误 408 Request Timeout。
顺便说一句,几个月前它运行良好。 请多多指教。
【问题讨论】: