本文整理汇总了PHP中League\Flysystem\Filesystem::addPlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::addPlugin方法的具体用法?PHP Filesystem::addPlugin怎么用?PHP Filesystem::addPlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::addPlugin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFilesystem
/**
* @return Filesystem
*/
public function getFilesystem()
{
if ($this->filesystem == null) {
$this->filesystem = new Filesystem(new Local($this->path));
$this->filesystem->addPlugin(new ListFiles());
}
return $this->filesystem;
}
示例2: boot
public function boot()
{
Storage::extend('qiniu', function ($app, $config) {
$client = new QiniuAdapter($config['accessKey'], $config['secretKey'], $config['bucket'], $config['domain'], $config['notify_url'], $config['pipeline']);
$filesystem = new Filesystem($client);
$filesystem->addPlugin(new UploadToken());
$filesystem->addPlugin(new PersistentStatus());
$filesystem->addPlugin(new PersistentFop());
$filesystem->addPlugin(new PrivateDownloadUrl());
$filesystem->addPlugin(new VerifyCallback());
return $filesystem;
});
}
示例3: boot
public function boot()
{
Storage::extend('oss', function ($app, $config) {
$ossconfig = ['AccessKeyId' => $config['access_id'], 'AccessKeySecret' => $config['access_key']];
if (isset($config['endpoint']) && !empty($config['endpoint'])) {
$ossconfig['Endpoint'] = $config['endpoint'];
}
$client = new \ALIOSS($ossconfig['AccessKeyId'], $ossconfig['AccessKeySecret'], $ossconfig['Endpoint']);
$filesystem = new Filesystem(new AliyunOssAdapter($client, $config['bucket'], $config['prefix']));
$filesystem->addPlugin(new initMultiUpload());
$filesystem->addPlugin(new mergeMultiInfo());
$filesystem->addPlugin(new uploadMultiPart());
$filesystem->addPlugin(new finishMultiUpload());
return $filesystem;
});
}
示例4: __construct
/**
* @param array $settings
* @param \League\Flysystem\AdapterInterface $adapter
*/
public function __construct(array $settings, AdapterInterface $adapter = null)
{
$adapter = $adapter ?: $this->createAdapter($settings);
$filesystem = new Filesystem($adapter, $settings);
$filesystem->addPlugin(new ListFiles());
$this->filesystem = $filesystem;
}
示例5: boot
public function boot()
{
Storage::extend('bos', function ($app, $config) {
$client = new BosClient($config['options']);
$filesystem = new Filesystem(new BaiduBosAdapter($client, $config['bucket']));
$filesystem->addPlugin(new PutFilePlugin());
return $filesystem;
});
}
示例6: boot
public function boot()
{
\Storage::extend('qiniu', function ($app, $config) {
$qiniu_adapter = new QiniuAdapter($config['access_key'], $config['secret_key'], $config['bucket'], $config['domain']);
$file_system = new Filesystem($qiniu_adapter);
$file_system->addPlugin(new PrivateDownloadUrl());
$file_system->addPlugin(new DownloadUrl());
$file_system->addPlugin(new ImageInfo());
$file_system->addPlugin(new ImageExif());
$file_system->addPlugin(new ImagePreviewUrl());
$file_system->addPlugin(new PersistentFop());
$file_system->addPlugin(new PersistentStatus());
$file_system->addPlugin(new UploadToken());
$file_system->addPlugin(new Fetch());
$file_system->addPlugin(new PutFile());
return $file_system;
});
}
示例7: init
/**
* @inheritdoc
*/
protected function init()
{
$this->fs = $this->options['filesystem'];
if (!$this->fs instanceof FilesystemInterface && !$this->fs instanceof \creocoder\flysystem\Filesystem) {
return $this->setError('A filesystem instance is required');
}
$this->fs->addPlugin(new UrlPlugin());
isset($this->options['icon']) ?: ($this->options['icon'] = $this->getIcon());
$this->root = $this->options['path'];
if ($this->options['glideURL']) {
$this->urlBuilder = UrlBuilderFactory::create($this->options['glideURL'], $this->options['glideKey']);
}
if ($this->options['imageManager']) {
$this->imageManager = $this->options['imageManager'];
} else {
$this->imageManager = new ImageManager();
}
return true;
}
示例8: boot
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
Storage::extend('oss', function ($app, $config) {
$accessId = $config['access_id'];
$accessKey = $config['access_key'];
$endPoint = $config['endpoint'];
$bucket = $config['bucket'];
$prefix = null;
if (isset($config['prefix'])) {
$prefix = $config['prefix'];
}
$client = new OssClient($accessId, $accessKey, $endPoint);
$adapter = new AliyunOssAdapter($client, $bucket, $prefix);
$filesystem = new Filesystem($adapter);
$filesystem->addPlugin(new PutFile());
$filesystem->addPlugin(new SignedDownloadUrl());
return $filesystem;
});
}
示例9: boot
public function boot()
{
class_alias('Illuminate\\Support\\Facades\\Storage', 'Storage');
//for Lumen5.2
\Storage::extend('qiniu', function ($app, $config) {
$qiniu_adapter = new QiniuAdapter($config['access_key'], $config['secret_key'], $config['bucket'], $config['domain'], $config['pipeline'], $config['notify_url']);
$file_system = new Filesystem($qiniu_adapter);
$file_system->addPlugin(new PrivateDownloadUrl());
$file_system->addPlugin(new DownloadUrl());
$file_system->addPlugin(new ImageInfo());
$file_system->addPlugin(new ImageExif());
$file_system->addPlugin(new ImagePreviewUrl());
$file_system->addPlugin(new PersistentFop());
$file_system->addPlugin(new PersistentStatus());
$file_system->addPlugin(new UploadToken());
$file_system->addPlugin(new PutFile());
$file_system->addPlugin(new Put());
return $file_system;
});
}
示例10: boot
public function boot()
{
Storage::extend('qiniu', function ($app, $config) {
$qiniu_adapter = new QiniuAdapter($config['access_key'], $config['secret_key'], $config['buckets'], $config['notify_url'] ? $config['notify_url'] : null);
$file_system = new Filesystem($qiniu_adapter);
$plugins = [PrivateDownloadUrl::class, DownloadUrl::class, ImageExif::class, ImageInfo::class, ImagePreviewUrl::class, PersistentFop::class, PersistentStatus::class, WithBucket::class, ToBucket::class, UploadToken::class];
foreach ($plugins as $plugin) {
$file_system->addPlugin(new $plugin());
}
return $file_system;
});
}
示例11: __construct
public function __construct(AdapterInterface $local, AdapterInterface $remote)
{
// Remember the local root path
$this->localRootPath = $local->getPathPrefix();
// Create the local filesystem
$local = new Filesystem($local);
$local->addPlugin(new ListWith());
$this->localFilesystem = $local;
// The remote filesystem
$remote = new Filesystem($remote);
// Create the manager with the local and remote filesystems
$this->manager = new MountManager(compact('local', 'remote'));
}
示例12: setUp
public function setUp()
{
parent::setUp();
// Set backend
$adapter = new AssetAdapter(ASSETS_PATH . '/DBFileTest');
$filesystem = new Filesystem($adapter);
$filesystem->addPlugin(new FlysystemUrlPlugin());
$backend = new AssetStoreTest_SpyStore();
$backend->setFilesystem($filesystem);
Injector::inst()->registerService($backend, 'AssetStore');
// Disable legacy
Config::inst()->remove(get_class(new FlysystemAssetStore()), 'legacy_filenames');
// Update base url
Config::inst()->update('Director', 'alternate_base_url', '/mysite/');
}
示例13: __construct
public function __construct($name = null, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);
/*
* TODO 测试依赖
*/
$accessId = 'you access id';
$accessKey = 'you access key';
$endPoint = 'oss-cn-beijing.aliyuncs.com';
$bucket = 'you bucket';
$client = new OssClient($accessId, $accessKey, $endPoint);
$adapter = new AliyunOssAdapter($client, $bucket);
$adapter->deleteDir('test');
$adapter->setPathPrefix('test');
$filesystem = new Filesystem($adapter);
$filesystem->addPlugin(new PutFile());
$this->filesystem = $filesystem;
}
示例14: boot
public function boot()
{
\Storage::extend('qiniu', function ($app, $config) {
if (isset($config['domains'])) {
$domains = $config['domains'];
} else {
$domains = ['default' => $config['domain'], 'https' => null, 'custom' => null];
}
$qiniu_adapter = new QiniuAdapter($config['access_key'], $config['secret_key'], $config['bucket'], $domains, $config['notify_url']);
$file_system = new Filesystem($qiniu_adapter);
$file_system->addPlugin(new PrivateDownloadUrl());
$file_system->addPlugin(new DownloadUrl());
$file_system->addPlugin(new ImageInfo());
$file_system->addPlugin(new ImageExif());
$file_system->addPlugin(new ImagePreviewUrl());
$file_system->addPlugin(new PersistentFop());
$file_system->addPlugin(new PersistentStatus());
$file_system->addPlugin(new UploadToken());
return $file_system;
});
}
示例15: getResources
function getResources($uploads_dir, $id, $maxWidth, $connection = 'default')
{
$attachments = Attachment::on($connection)->where('id', $id)->get();
if (count($attachments) == 1) {
$attachment = $attachments[0];
switch ($attachment->source) {
case Source::EMAIL:
$adapter = new Local($uploads_dir . '/email/');
break;
case Source::TWITTER:
$adapter = new Local($uploads_dir . '/twitter/');
break;
case Source::TELEGRAM:
$adapter = new Local($uploads_dir . '/telegram/');
break;
default:
break;
}
$filesystem = new Filesystem($adapter);
$filesystem->addPlugin(new ListWith());
if ($filesystem->has($attachment->filePath)) {
$data = $filesystem->read($attachment->filePath);
$fp['data'] = $data;
$fp['mime'] = $filesystem->getMimetype($attachment->filePath);
if ($maxWidth > 0) {
$imagine = new \Imagine\Gd\Imagine();
$image = $imagine->load($data);
$size = $image->getSize();
if ($size->getWidth() > $maxWidth) {
// AWIDTH : AHEIGHT = NWIDTH : NHEIGHT
// HHEIGHT = AHEIGHT * NWIDTH / AWIDTH
$height = $size->getHeight() * $maxWidth / $size->getWidth();
$width = $maxWidth;
$fp['data'] = $image->resize(new Box($width, $height), ImageInterface::FILTER_UNDEFINED)->show('png');
//FILTER_QUADRATIC
}
}
return $fp;
}
}
return false;
}