thephpleague / flysystem-rackspace Goto Github PK
View Code? Open in Web Editor NEWFlysystem Adapter for Rackspace
Flysystem Adapter for Rackspace
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Composer spits out this warning in every single composer command I use... Perhaps consider an update within this library?
is this package compatible to make integration to softlayer object storage ?
Hi, since the last release I got this:
Type error: Argument 1 passed to LeagueFlysystemRackspaceRackspaceAdapter_XXXXX::__construct() must be an instance of OpenCloud\ObjectStore\Resource\Container, instance of Closure given, called in /var/www/demophonie/app/cache/dev/appDevDebugProjectContainer.php on line 6614
I tried alone to debug it but without results.
Have you any idea ?
I'm under Symfomy 2.8.2 and PHP7.0.2. From my point of view, issue is linked to dependency injection.
Thanks.
Hi,
openstack v1.0 doesnt work on this package.
So I am using Rackspace with my Symfony2 project,
The problem occurs when I want to read from stream:
$filesystem = $this->container->get('oneup_flysystem.XXXX_filesystem');
// Retrieve a read-stream
$stream = $filesystem->readStream('63335b4af21bf2f76145e21b1130570d2356b274.jpg');
$contents = stream_get_contents($stream);
if(is_resource($stream))
{
fclose($stream);
}
var_dump($contents);
The file is there, the $contents is shown as empty string.
When I change readStream()
to read()
, it dumps all the data of the jpg file, but no data with readStream()
.
Any idea why?
PS: As per documentation in php.net, if stream_get_contents
fails it will return FALSE not empty string.
Also note that writeStream()
works just fine...
Hi,
We're using the adapter to use an object store as our filesystem, but creating directories was not working. After investigating we got to the conclusion the createDir method only returns a array with the dirname.
Altough Rackspace doesn't officially supports the use of folders, there is a way of getting this to work. In order for directories to work you need to send two additional headers with the request.
Contents: None
Content-Type: application/directory
I've changed the createDir and normalizeObject to work with this solution.
createDir
public function createDir($dirname, Config $config)
{
// return ['path' => $dirname];
$headers = [];
if ($config->has('headers')) {
$headers = $config->get('headers');
}
if (!key_exists('Contents', $headers)) {
$headers['Contents'] = 'None';
}
if (!key_exists('Content-Type', $headers)) {
$headers['Content-Type'] = 'application/directory';
}
$config->set('headers', $headers);
return $this->write($dirname, '', $config);
}
normalizeObject
protected function normalizeObject(DataObject $object)
{
$name = $object->getName();
$name = $this->removePathPrefix($name);
$mimetype = explode('; ', $object->getContentType());
return [
'type' => ((in_array('application/directory', $mimetype)) ? 'dir' : 'file'),
'dirname' => Util::dirname($name),
'path' => $name,
'timestamp' => strtotime($object->getLastModified()),
'mimetype' => reset($mimetype),
'size' => $object->getContentLength(),
];
}
Is this something you'll be willing to integrate in the adapter, if so do you need a pull request (never done that before :-)) or can you manually use the above code adjustments.
The rackspace adapter now has a deleteObject method (see rackspace/php-opencloud#651), instead of having to download the object to delete it. Could this be added to the adapter?
I can send a PR if I get time this week.
Rackspace uses
$transfer = $container->setupObjectTransfer(array(
'name' => 'video.mov',
'path' => '/home/jamie/video.mov',
'metadata' => array(
'Author' => 'Jamie'
),
'concurrency' => 4,
'partSize' => 1.5 * Size::GB
));
$transfer->upload();
I've just spotted an inconsistency between the Local adapter and the Rackspace one:
$localFilesystem = new Filesystem(new Local('/path/to/dir'));
$localFilesystem->write('some/file', 'Hello');
$localStream = $localFilesystem->readStream('some/file');
echo stream_get_contents($localStream); // outputs Hello
$rackspaceFilesystem = new Filesystem(new RackspaceAdapter($container));
$rackspaceFilesystem->write('some/file', 'Hello');
$rackspaceStream = $rackspaceFilesystem->readStream('some/file');
echo stream_get_contents($rackspaceStream); // outputs an empty string
I think the stream should always be at the beginning of the file, or it's difficult to just change the adapter and get the same result.
It looks like there's a new version of the OpenCloud API coming out - according to rackspace/php-opencloud#655 it could be considered production ready.
Is it worth looking at updating? The API looks to be fairly similar.
Instantiating Flysystem/Rackspace fails with PHP8. I've had this working with PHP7.4 for at least a year or so.
On PHP8, we get:
Deprecated: Required parameter $archive follows optional parameter $path in /var/www/html/includes/vendor/rackspace/php-opencloud/lib/OpenCloud/ObjectStore/Service.php on line 167
PHP Fatal error: Uncaught Guzzle\Common\Exception\InvalidArgumentException: Invalid handle provided in /var/www/html/includes/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlHandle.php:237
Stack trace:
#0 /var/www/html/includes/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlHandle.php(223): Guzzle\Http\Curl\CurlHandle->__construct()
... and so on
Any fix for this?
It's mentioned briefly in the docs for OpenCloud that file names should be URL encoded if they're non-standard. Should the Rackspace adapter be handling this, or should I ensure my filenames are URLEncoded before passing them down the chain?
Hello,
We're using this wonderful adapter in our workers dispatching queued jobs from different Laravel events.
Lately we're seeing errors in some of those workloads when trying to upload files into the Cloudfiles bucket, those errors come and go, and after talking to the Rackspace team seems there might be some problem with the token expiration.
Rackspace is suggesting to call $client->authenticate()
that would refresh the expired token for a new one, but it might be overkill to reauthenticate every single time.
Did you guys got any similar reports about expired tokens in long-lived worker processes ? Any clue to get over it ?
Here's the error trace:
Guzzle\Http\Exception\ClientErrorResponseException: Client error response
[status code] 401
[reason phrase] Unauthorized
[url] https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_..../user/123456 in /home/worker/.../vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43
Stack trace:
#0 /home/worker/.../vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(145): Guzzle\Http\Exception\BadResponseException::factory(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response))
...
#16 /home/worker.../vendor/league/flysystem-rackspace/src/RackspaceAdapter.php(93): OpenCloud\ObjectStore\Resource\Container->uploadObject('user/4564_1...', '\xFF\xD8\xFF
.....
Thanks!
Hello.
The last commit was in 2016, the last commit of dependency rackspace/php-opencloud was in 2017, dependency guzzle/guzzle was abandoned since 2015.
Is this package still maintained??
This package uses rackspace/php-opencloud 1.16, and that is broken due to guzzle/guzzle being abandoned in favor of guzzlehttp.
I tried to get a URL of a object, and I did not find any other way then making "getObject" method public and then call "$disk->getDriver()->getAdapter()->getObject('uploads/file.txt')->getUrl()"
Is there any other way, or implementing "getObjectUrl" method would be a good solution?
How can I use the rackspace servicenet endpoint for faster connections, sine my servers are on rackspace datacenter
Thanks!
I was making use of the Rackspace adapter via flysytsem .
The code is as below .
$flysystem = new Filesystem(new RackspaceAdapter($container));
$fp = fopen($file, 'r+');
if ($fp) {
$flysystem->writeStream($destination, $fp);
fclose($fp);
}
I noticed when trying to close it says not a resource.
PHP Warning: fclose(): xx is not a valid stream resource in ...
Wonder whether flysystem at some point is automatically closing the same ?
Good thing is it is sending the data to the Cloud. So the file is already present on both local and server :) .
In the AWS S3 adapter https://github.com/thephpleague/flysystem-aws-s3-v3/blob/master/src/AwsS3Adapter.php#L583 the ContentType is attempted to be set programmatically and can be overridden by setting a Config['ContentType']
However for the Rackspace Adapter this isn't even attempted and depends on the user to update the header with a Content-Type parameter when uploading.
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.