You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am able to user GoogleCloudStorage (gcs) and everything is working fine. What I have having trouble with is "hiding" all folders expect the one I want a user to have access to. In that one folder The user should have full access. I am using "barryvdh/laravel-elfinder": "^0.5.2",
My config file is default except for
/*
|--------------------------------------------------------------------------
| Upload dir
|--------------------------------------------------------------------------
|
| The dir where to store the images (relative from public)
|
*/
'dir' => 'none',
/*
|--------------------------------------------------------------------------
| Filesystem disks (Flysytem)
|--------------------------------------------------------------------------
|
| Define an array of Filesystem disks, which use Flysystem.
| You can set extra options, example:
|
| 'my-disk' => [
| 'URL' => url('to/disk'),
| 'alias' => 'Local storage',
| ]
*/
'disks' => [
'gcs' => [
'alias' => 'Cloud File Storage'
]
],
I have a middleware with two function that are NOT doing what I thought they would
public function handle(Request $request, Closure $next){
$disk = Storage::disk('gcs');
$thisOrgId = current_org()->ID;
$thisOrgName = current_org()->OrganizationName;
$dirName = $thisOrgId;
if ($dirName != '' && !$disk->directoryExists($dirName)) {
$disk->makeDirectory($dirName);
}
$dirs = $disk->directories();
$this->app = app();
// $roots = $this->app->config->get('elfinder.roots', []);
if (empty($roots)) {
$roots = [];
foreach ($dirs as $key => $dir) {
// if the dir should be shown
if($dir == $thisOrgId){
array_push($roots , [
'driver' => 'gcs', // driver for accessing file system (REQUIRED)
'path' => $dir, // path to files (REQUIRED)
'startPath' => $dir,
'URL' => config('app.google.bucket_prefix'), // URL to files (REQUIRED)
'accessControl' => $this->access(
'hidden',
config('app.google.bucket_prefix').'/'.$dir,'gcs',
'accessControlData',
true,
'/'.$dir), // https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1#accesscontrol
'alias' => $thisOrgName,
'uploadAllow' => array('image'),
'uploadMaxSize' => '5M',
'attributes' => array(
array(
'pattern' => '/\'/', // Dont write or delete to this but subfolders and files
'read' => true,
'write' => true,
'locked' => true
)
)
]);
} else {
// hide the dir
array_push($roots , [
'driver' => 'gcs', // driver for accessing file system (REQUIRED)
'path' => $dir, // path to files (REQUIRED)
'URL' => config('app.google.bucket_prefix'), // URL to files (REQUIRED)
'attributes' => array(
array(
'pattern'=> $dir,
'hidden'=>true
)
)
]);
}
}
}
$opts = $this->app->config->get('elfinder.options', array());
$bind = '';
$plugin = '';
$opts = array_merge(['bind'=>$bind,'plugin'=>$plugin,'roots' => $roots], $opts);
return $next($request);
}
function access($attr, $path, $data, $volume, $isDir, $relpath) {
$basename = basename($path);
return $basename[0] === '.' // if file/folder begins with '.' (dot)
&& strlen($relpath) !== 1 // but with out volume root
? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
: null; // else elFinder decide it itself
}
If I dump it looks like the example I have seen, What am I doing wrong?
The text was updated successfully, but these errors were encountered:
I am able to user GoogleCloudStorage (gcs) and everything is working fine. What I have having trouble with is "hiding" all folders expect the one I want a user to have access to. In that one folder The user should have full access. I am using "barryvdh/laravel-elfinder": "^0.5.2",
My config file is default except for
/*
|--------------------------------------------------------------------------
| Upload dir
|--------------------------------------------------------------------------
|
| The dir where to store the images (relative from public)
|
*/
'dir' => 'none',
I have a middleware with two function that are NOT doing what I thought they would
If I dump it looks like the example I have seen, What am I doing wrong?
The text was updated successfully, but these errors were encountered: