Comments (7)
Can you provide me with some sample code so I can replicate this?
Thanks
from flysystem-google-cloud-storage.
My connector:
function googleCloud($bucket)
{
$credentials = new \Google_Auth_AssertionCredentials(
'gcstest@MY_PROJECT.iam.gserviceaccount.com',
[\Google_Service_Storage::DEVSTORAGE_FULL_CONTROL],
file_get_contents(set_realpath('MY_SECRET.p12')),
'notasecret'
);
$client = new \Google_Client();
$client->setAssertionCredentials($credentials);
$client->setDeveloperKey('MY_KEY');
$service = new \Google_Service_Storage($client);
$adapter = new GoogleStorageAdapter($service, $bucket);
return $adapter;
}
public function elfinder_init()
{
$this->load->helper('path');
$opts = array(
'roots' => array(
array(
'id' => 'root',
'driver' => 'Flysystem',
'alias' => 'CS Root',
'URL' => 'https://storage.googleapis.com/MY_BUCKET/',
'filesystem' => new Filesystem($this->googleCloud('MY_BUCKET')),
'separator' => '/'
)
)
);
$this->load->library('elfinder_lib', $opts);
}
from flysystem-google-cloud-storage.
Please look at #23 and #24 as I believe it is all connected.
You can replicate this by doing the following:
In the root bucket, create a directory (using the GCS console) then upload a file into the new directory.
In elFinder, you will now see two directories under the main root bucket, with the same name. One will contain the file you uploaded, the other will be empty.
I believe this issue and the two I linked are all related. Basically, the adapter is not recognising directories properly and simply normalises then to be files (if you change the type
to directory
on line 139 elFinder will list everything as directories (even files obviously) but previously "invisible" directories are now visible.
Clearly some bugs here.
from flysystem-google-cloud-storage.
Below is a basic fix for the issue. It will need testing but seems to work for me.
protected function normaliseObject(\Google_Service_Storage_StorageObject $object)
{
$type = 'file';
if ($object->size == '0')
{
$type = 'dir';
}
return [
'type' => $type,
'dirname' => Util::dirname($object->getName()),
'path' => $type == 'file' ? $object->getName() : rtrim($object->getName(), '/'),
'timestamp' => strtotime($object->getUpdated()),
'mimetype' => $object->getContentType(),
'size' => $object->getSize(),
];
}
from flysystem-google-cloud-storage.
Is this related to #23
With that proposed fix of mine in place, it seems to be resolved:
$filesystem->createDir('zzzz');
$filesystem->put('zzzz', 'hello world');
var_dump($filesystem->listContents());
array(2) {
[0]=>
array(8) {
["type"]=>
string(4) "file"
["dirname"]=>
string(0) ""
["path"]=>
string(5) "zzzzz"
["timestamp"]=>
int(1463658746)
["mimetype"]=>
string(10) "text/plain"
["size"]=>
string(2) "11"
["basename"]=>
string(5) "zzzzz"
["filename"]=>
string(5) "zzzzz"
}
[1]=>
array(8) {
["type"]=>
string(3) "dir"
["dirname"]=>
string(0) ""
["path"]=>
string(5) "zzzzz"
["timestamp"]=>
int(1463658744)
["mimetype"]=>
string(10) "text/plain"
["size"]=>
string(1) "0"
["basename"]=>
string(5) "zzzzz"
["filename"]=>
string(5) "zzzzz"
}
}
from flysystem-google-cloud-storage.
Yes, it is related, I didn't realise at the time :)
from flysystem-google-cloud-storage.
Fixed in release 1.0.4 - https://github.com/Superbalist/flysystem-google-storage/releases/tag/1.0.4
from flysystem-google-cloud-storage.
Related Issues (20)
- Renaming and moving Folders does not work HOT 1
- Function getOptionsFromConfig() is not working HOT 1
- undefined method: getUrl(); HOT 1
- get url from firebase storage using php
- has function does not return true for directories HOT 2
- upload fails with uniform access controls HOT 4
- ReadMe Correction for getUrl
- Supporting Flysystem 2.x HOT 4
- Getting 404 when i try to delete directory.
- File stream is dropped on writeStream() HOT 5
- Question: is it possible to set Cache-Control? HOT 1
- Authetification Issue HOT 2
- What's the status of this project? HOT 2
- Dependencies flysystem
- Could you update the library
- How to delete a dir with millions of files?
- PHP Warning thrown after asset Uploaded - stream provided gets corrupted HOT 1
- GoogleStorageAdapter::deleteDir fails to delete a directory HOT 2
- Is there a reason to explicitly set the visibility if not passed? HOT 7
- Changes to google api endpoint HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flysystem-google-cloud-storage.