Comments (6)
Hi,
this driver is focused on the case when useDisplayPaths==true so the support for a false case might be lacking. However, when you call the createDir function you get back an array. The path should contain the id. Does it not?
See this snippet from the createDir:
...
$folder = $this->createDirectory($name, $pdir !== '' ? basename($pdir) : $pdir);
if ($folder !== null) {
$itemId = $folder->getId();
$this->cacheFileObjects[$itemId] = $folder;
$this->cacheHasDirs[$itemId] = false;
$this->cacheObjects([$itemId => $folder]);
$path_parts = $this->splitFileExtension($name);
$result = [
'path' => Util::normalizeDirname($pdir).'/'.($this->useDisplayPaths ? $name : $itemId), // <-here the $itemId should be the folder ID
'filename' => $path_parts['filename'],
'extension' => $path_parts['extension']
];
return $result;
}
return false;
...
from flysystem-google-drive-ext.
Also acording Flysystems V1 Docs you have to use createDir
, not 'createDirectory', Flysystems Docs
but if you are using createDirectory
, maybe with $result->getId();
from flysystem-google-drive-ext.
@masbug sorry I didn't mentioned it I was asking for branch 2.x which I think uses Flysystems V2 where createDir
and CreateDirectory
functions are the opposite from version 1.x
from flysystem-google-drive-ext.
flysystem-google-drive-ext/src/GoogleDriveAdapter.php
Lines 765 to 776 in 237f5f3
@unsa-cdn on V2 everything changes(
CreateDirectory
returns void) you has to use FileAttributes
or DirectoryAttributes
, Flysystems V2 docsboth has
function extraMetadata(): array
So, you can use: $adapter->getMetadata
or $adapter->listContents
and iterate a list of FileAttributes
$file=$adapter->getMetadata('path/to/file.txt'); //can be directory
if($file){
$id=$file->getMetadata()['id']
}
because: $result = ['id' => $id];
and
return new FileAttributes($result['display_path'],$object->getSize(),$visibility, $object->getModifiedTime(),$object->mimeType,$result);
flysystem-google-drive-ext/src/GoogleDriveAdapter.php
Lines 1070 to 1075 in 237f5f3
There is a PR for more direct access, but it's a breaking change github.com/thephpleague/flysystem/pull/1324
If something doesn't work or can be improved, i can make a PR
from flysystem-google-drive-ext.
I see I need to provide a path to this getMetadata
function but the way google drive woks is with Ids. I would need to migrate my current database to use display paths instead of storing Ids I don't think so. Then I guess I will have to stay in V1 of flysystem.
Thank you for your help @erikn69
from flysystem-google-drive-ext.
V2 its a headacke with the throws and this package is focused on the case when useDisplayPaths==true
from flysystem-google-drive-ext.
Related Issues (20)
- creating a new folder in my drive HOT 2
- Backup failed because: Unable to write file at location: HOT 11
- Invalid value at 'payload' (Map) ? HOT 6
- Error in masbug because upgrade system Google API HOT 5
- Duplicate root directories created when instantiating the adapter HOT 3
- 401 Request had invalid authentication credentials (laravel jobs) HOT 4
- Problem with spatie laravel backup - League\Flysystem\UnableToReadFile HOT 8
- Don't list files and Directories in shared folder HOT 1
- Laravel 10 support HOT 2
- Can't display paths, just IDs HOT 1
- How to move app to live HOT 1
- Argument #1 ($value) must be of type Countable|array, null given in GoogleDriveAdapter.php:1037 HOT 3
- Fails to report delete error
- Moving folders will fall into the trash HOT 3
- Allowed memory size issue HOT 1
- create,delete,rename folder,get folder listing and data using folder id instead of name ,to remove duplicacy of same folder name HOT 2
- Rename Directory using laravel HOT 5
- useDisplayPaths is false, but return original filename HOT 4
- On live Server, google drive backup is giving error! HOT 1
- cannot list directory shortcuts HOT 2
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-drive-ext.