softlayer / softlayer-object-storage-php Goto Github PK
View Code? Open in Web Editor NEWSoftLayer Object Storage PHP Client
License: Other
SoftLayer Object Storage PHP Client
License: Other
Please provide a way to set arbitrary CURL options, or at least all timeout settings.
When trying to load large objects, the request may time out.
To work around this, you can set the timeout for the entire request to a few minutes maybe.
However this may cause your downloads to wait for a very long time if there are connection issues, because CURL defaults to very high timeout values e.g. for the connect phase (5 minutes), which you may not want.
Looking at the source of ObjectStorage_Http_Adapter_Curl, it seems that there are only a few hard-coded CURL options that can be set at all.
Rather than hard-code yet another option, I think it would be better to just provide a generic way to set any CURL option, e.g. via an array curloptions
in the $options
argument to the ObjectStorage
constructor.
HI
How can i get progress when uploading very big file? Is there hook for this?
thanks
I am currently implementing the PHP code for the Object Storage system.
Everything seems to be working fine, however, I'm receiving an error about an "Undefined variable".
Notice: Undefined variable: host in /lib/ObjectStorage/Http/Client.php on line 45
Notice: Undefined variable: host in /lib/ObjectStorage/Http/Client.php on line 54
Notice: Undefined variable: host in /lib/ObjectStorage/Http/Client.php on line 62
Notice: Undefined variable: host in /lib/ObjectStorage/Http/Client.php on line 66
The variable in question is:
self::$client[$host]
The $host key is not defined anywhere in this class. I was able to correct the problem by changing $host from a variable into a string "host".
Is this correct??
Trying to add this with any other framework and spl_autoload_register conflicts with everything else causes all kinds of errors.
Under the section titled "Traversing containers or objects"
foreach ($results->objects as $shallowObject) {
should be changed to
foreach ($container->objects as $shallowObject) {
I'm making the following call:
$res = $os->with('container/filename.txt')->delete();
But instead of $res getting set to a boolean value, an exception is being thrown, which is not being caught, so a fatal error occurs:
Error level: 1
Error message: Uncaught exception 'ObjectStorage_Exception_Http_NotFound' with message 'Not Found' in /var/www/vhosts/jjriv.assignthis.com/app/LocalLib/ObjectStorage/ObjectStorage.php:531
Stack trace:
#0 /var/www/vhosts/jjriv.assignthis.com/app/LocalLib/ObjectStorage/ObjectStorage/Exception/Http.php(10): ObjectStorage_Exception_Http->throwException(404, NULL, '/var/www/vhosts...', 531)
#1 /var/www/vhosts/jjriv.assignthis.com/app/LocalLib/ObjectStorage/ObjectStorage.php(531): ObjectStorage_Exception_Http->__construct(NULL, 404)
#2 /var/www/vhosts/jjriv.assignthis.com/app/LocalLib/ObjectStorage/ObjectStorage/Abstract.php(607): ObjectStorage->delete(Object(ObjectStorage_Object))
#3 /var/www/vhosts/jjriv.assignthis.com/app/cron/upload_garbage_collection.php(56): ObjectStorage_Abstract->delete()
But in the unit test docs, the delete() is not performed inside a try/catch clause:
https://github.com/softlayer/softlayer-object-storage-php/blob/master/tests/ObjectTest.php
And according to the Openstack documentation, 404 is a valid response for when the object does not exist:
http://docs.openstack.org/api/openstack-object-storage/1.0/content/delete-object.html
Do I need to put my delete() code inside a try/catch or is this a bug? Thanks!
This project needs some versioning love so we can better manage releases and properly version any API-breaking changes.
The following code is expected to return all objects under the given prefix as $container->objects
$client = new ObjectStorage($host, $username, $password);
$objectToRequest = 10000;
$container = $client->with('container')->setParam('prefix','a prefix')->get($objectToRequest);
while (count($container->objects) < $container->getObjectCount()) {
$obj = end($container->objects);
reset($container->objects);
$marker = $obj->getPath();
$container->get($objectToRequest, $marker);
}
However, the code runs indefinitely. And when I add:
echo count($container->objects).' = '.$container->getObjectCount();
in the loop, I see that the values are static where $container->getObjectCount()
shows the number of all objects in the unprefixed container, while count($container->objects)
shows the number of all objects in the prefixed container.
The reason for the loop is because get()
maximum returns 10000 objects per call, so for prefixes which have more than 10000 objects the call must be repeated with marker as last retrieved object.
My question is:
Regards,
Mario
Is this compatible with bluemix?
I tried to do credentials and pull my container
this always come
Fatal error: Uncaught ObjectStorage_Exception_Http_NotFound: Not Found in /Applications/XAMPP/xamppfiles/htdocs/jti-ats/vendor/softlayer/objectstorage/lib/ObjectStorage.php:166 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/jti-ats/vendor/softlayer/objectstorage/lib/ObjectStorage.php(166): ObjectStorage_Exception_Http::factory('Not Found', 404) #1 /Applications/XAMPP/xamppfiles/htdocs/jti-ats/vendor/softlayer/objectstorage/lib/ObjectStorage.php(94): ObjectStorage->authenticate() #2 /Applications/XAMPP/xamppfiles/htdocs/jti-ats/vendor/softlayer/objectstorage/lib/ObjectStorage.php(604): ObjectStorage->getAuthenticationData() #3 /Applications/XAMPP/xamppfiles/htdocs/jti-ats/vendor/softlayer/objectstorage/lib/ObjectStorage/Abstract.php(608): ObjectStorage->delete(Object(ObjectStorage_Container)) #4 /Applications/XAMPP/xamppfiles/htdocs/jti-ats/test.php(18): ObjectStorage_Abstract->delete() #5 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/jti-ats/vendor/softlayer/objectstorage/lib/ObjectStorage.php on line 166
Please change:
"autoload": { "psr-0": { "ObjectStorage_": "lib/", "": "lib/" } }
to
"autoload": { "psr-0": { "ObjectStorage_": "lib/" } }
It's causing a lot of problems
How can i get modified date of file on Object Storage?
Could you please give me a sample code?
Thank you very much
When using this function, it responded only old container. New containers did NOT respond.
$objects = $this->_object_storage
->with('')
->setContext('search')
->setFilter('type', 'container') // object or container
->setFilter('', '')
->setMime('json') //json - xml - plain
->get();
How can i fix it?
Thanks
Set a proper user-agent header in each of the HTTP adapters to identify this particular library; the version should be included (see also #23).
The file lib\ObjectStorage\Abstract.php
has error in line 352 throw new ObjectStorage_Exception(null, 'Invalid MIME type is provided.');
.
It must be throw new ObjectStorage_Exception('Invalid MIME type is provided.');
Hi,
Thought I would log this issue.
Here is the 'out-of-the-box' code I am using for uploading files:
$options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);
$objStorage = new ObjectStorage('', '', '', $options);
try {
$newFile = $objStorage->with('RemoteFilePath')
->setLocalFile($PathTolocalFile)
->create();
return $newFile->getUrl();
}
catch (Exception $e) {
return $e->getMessage();
}
For some reason, uploading a file that is under 1Mb works. But any file with a size bigger than this, the ->create() request eventually times out, no exception is thrown and I keep getting these error in my log:
xxx.xxx.xxx.xx - [05/06/16 03:47:02] Warning: fwrite(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry (/var/www/vendor/softlayer/objectstorage/lib/ObjectStorage/Http/Adapter/Socket.php:132)
As those bindings are essentially a wrapper round curl, I then tested with CURL myself see if I could upload a file bigger than 1M to Softlayer Storage Container. It turns out it succeeded using CURL both on my dev machine and staging server!
curl -i -XPUT -H "X-Auth-Token: {{MyAuthToken}}" --data-binary "@BigFile.txt" https://lon02.objectstorage.softlayer.net/v1/{{MyAuthTokenKey}}/{{MyContainer}}/BigFile.txt
Have you ever come across this? Is this my machine?
Thanks
We currently use this library and it works great. But, today SoftLayer turned off SSLv3 on their ObjectStorage network in response to the POODLE vulnerability.
Is there any way to use this library with the CURL adapter and TLSv1?
At present, it doesn't work at all :(
HI
How do I upload large object with php?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.