0
votes

We are trying to upload a file into Object Storage with PHP Library(https://github.com/softlayer/softlayer-object-storage-php) and getting 408 Request Timeout errors.

Request Timeout

The server has waited too long for the request to be sent by the client.

This happens when we upload a file with size around 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());
  }
}

I tried uploaded 2 files and the first file (sample_617K.zip) was successfully uploaded. Second file (sample_1_3M.zip) returned with error 408 Request Timeout after 5 minutes.

By the way, It was working fine few months back. Please advice further.

2

2 Answers

1
votes

After some debug/testing, i used CURL for the adapter settings instead of SOCKET and it get fixed. :)

0
votes

I had success to upload files bigger than 1 MB. I uploaded two files (4.22 MB and 4.66 MB) using your script and it works fine. Something weird from your side, did you try increasing the timeout?