Open danvfebra opened 4 years ago
@danvfebra Did you find solution ?
@danvfebra Did you find solution ?
none.. i had to manually set the files in DO
@danvfebra I found i soluion but it look ugly
'roots' => [ [ 'driver' => 'Flysystem', 'filesystem' => new \League\Flysystem\Filesystem( new \League\Flysystem\AwsS3v3\AwsS3Adapter( new \Aws\S3\S3Client([ 'endpoint' => env('DO_SPACES_ENDPOINT'), 'credentials' => [ 'key' => env('DO_SPACES_KEY'), 'secret' => env('DO_SPACES_SECRET') ], 'region' => env('DO_SPACES_REGION'), 'version' => 'latest', ]), env('DO_SPACES_BUCKET'), '', ['ACL' => 'public-read'] ) ), 'alias' => 'spaces', 'URL' => 'https://'.env('DO_SPACES_BUCKET').'.sgp1.digitaloceanspaces.com', ] ],
@vanthao03596 yes it helped me too, my code is here ['ACL' => 'public-read'] added this and it is working now
<?php
error_reporting(0); // Set E_ALL for debuging
// load composer autoload before load elFinder autoload If you need composer
require './vendor/autoload.php';
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
// elFinder autoload
require './autoload.php';
// ===============================================
/**
* Simple function to demonstrate how to control file access using "accessControl" callback.
* This method will disable accessing files/folders starting from '.' (dot)
*
* @param string $attr attribute name (read|write|locked|hidden)
* @param string $path absolute file path
* @param string $data value of volume option `accessControlData`
* @param object $volume elFinder volume driver object
* @param bool|null $isDir path is directory (true: directory, false: file, null: unknown)
* @param string $relpath file path relative to volume root directory started with directory separator
* @return bool|null
**/
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
}
//!!!!!!!!!!!!!!AWS CONFIG HERE!!!!!!!!!!!!!!!
$aws_config = [
"key" => "********",
"secret" => "*********************",
"region" => "us-west-1",
"bucket" => "xxxx-xxxx-xx"
];
$aws_url = "http://" . $aws_config["bucket"] . ".s3." . $aws_config["region"] . ".amazonaws.com";
$client = new S3Client(
Array ( "driver" => "s3",
"key" => $aws_config["key"],
"secret" => $aws_config["secret"],
"scheme" => $_SERVER['REQUEST_SCHEME'],
"region" => $aws_config["region"],
"bucket" => $aws_config["bucket"],
"url" => $aws_url,
"version" => "latest",
"credentials" => Array (
"key" => $aws_config["key"],
"secret" => $aws_config["secret"]
)
)
);
$adapter = new AwsS3Adapter($client, $aws_config["bucket"], '', ['ACL' => 'public-read']);
$filesystem = new Filesystem($adapter, Array ( "url" => $aws_url ));
// Documentation for connector options:
// https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
$opts = array(
// 'debug' => true,
'roots' => [
[
'driver' => 'Flysystem',
'alias' => 'DOD',//Change to anything you like
'filesystem' => $filesystem,
'URL' => $aws_url,
'tmbURL' => 'self',
//
'uploadDeny' => array('all'), // Recomend the same settings as the original volume that uses the trash
'uploadAllow' => array(
'image',
'text/plain',
'application/pdf',
'application/msword',
'application/vnd.ms-excel',
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
),// Same as above
'accessControl' => 'access',
]
]
);
// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();
How can I make a default configuration when uploading a file it sets its permission to public.
NOTE: I'm using Digital Ocean spaces.