本文整理汇总了PHP中League\Flysystem\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: writeStream
/**
* Write a new file using a stream.
*
* @param string $path
* @param resource $resource
* @param Config $config Config object
*
* @return array|false false on failure file meta data on success
*/
public function writeStream($path, $resource, Config $config)
{
$path = $this->applyPathPrefix($path);
$params = $config->get('params', null);
$mime = $config->get('mime', 'application/octet-stream');
$checkCrc = $config->get('checkCrc', false);
list($ret, $code) = $this->ufileSdk->put($path, $resource, ['Content-Type' => $mime]);
}
开发者ID:xujif,项目名称:ucloud-ufile-storage,代码行数:17,代码来源:UcloudUfileAdapter.php
示例2: write
/**
* @inheritdoc
*/
public function write($path, $contents, Config $config)
{
$type = 'file';
$result = compact('contents', 'type', 'path');
if ($visibility = $config->get('visibility')) {
$result['visibility'] = $visibility;
}
return $result;
}
开发者ID:laerciobernardo,项目名称:CodeDelivery,代码行数:12,代码来源:NullAdapter.php
示例3: write
/**
* {@inheritdoc}
*/
public function write($path, $contents, Config $config)
{
$location = $this->applyPathPrefix($path);
$headers = [];
if ($config && $config->has('headers')) {
$headers = $config->get('headers');
}
$response = $this->container->uploadObject($location, $contents, $headers);
return $this->normalizeObject($response);
}
开发者ID:syntropysoftware,项目名称:cryptoffice-frontend,代码行数:13,代码来源:RackspaceAdapter.php
示例4: getOptionsFromConfig
/**
* Returns an array of options from the config.
*
* @param Config $config
* @return array
*/
protected function getOptionsFromConfig(Config $config)
{
$options = [];
if ($config->has('visibility')) {
$options['acl'] = $config->get('visibility') === AdapterInterface::VISIBILITY_PUBLIC ? 'publicRead' : 'private';
}
if ($config->has('mimetype')) {
$options['mimetype'] = $config->get('mimetype');
}
// TODO: consider other metadata which we can set here
return $options;
}
开发者ID:codixor,项目名称:flysystem-google-storage,代码行数:18,代码来源:GoogleStorageAdapter.php
示例5: createDir
/**
* {@inheritdoc}
*/
public function createDir($dirname, Config $config)
{
$location = $this->applyPathPrefix($dirname);
$umask = umask(0);
$visibility = $config->get('visibility', 'public');
if (!is_dir($location) && !@mkdir($location, $this->permissionMap['dir'][$visibility], true)) {
$return = false;
} else {
$return = ['path' => $dirname, 'type' => 'dir'];
}
umask($umask);
return $return;
}
开发者ID:pkdevboxy,项目名称:filesystem,代码行数:16,代码来源:Local.php
示例6: handle
/**
* Handle.
*
* @param string $path
* @param string $localFilePath
* @param array $config
* @return bool
*/
public function handle($path, $localFilePath, array $config = [])
{
if (!method_exists($this->filesystem, 'getAdapter')) {
return false;
}
if (!method_exists($this->filesystem->getAdapter(), 'putFile')) {
return false;
}
$config = new Config($config);
if (method_exists($this->filesystem, 'getConfig')) {
$config->setFallback($this->filesystem->getConfig());
}
return (bool) $this->filesystem->getAdapter()->putFile($path, $localFilePath, $config);
}
开发者ID:apollopy,项目名称:flysystem-aliyun-oss,代码行数:22,代码来源:PutFile.php
示例7: write
/**
* {@inheritdoc}
*/
public function write($path, $contents, Config $config)
{
$location = $this->applyPathPrefix($path);
$this->ensureDirectory(dirname($location));
if (($size = file_put_contents($location, $contents)) === false) {
return false;
}
$type = 'file';
$result = compact('contents', 'type', 'size', 'path');
if ($visibility = $config->get('visibility')) {
$result['visibility'] = $visibility;
$this->setVisibility($path, $visibility);
}
return $result;
}
开发者ID:njohns-pica9,项目名称:flysystem-vfs,代码行数:18,代码来源:VfsAdapter.php
示例8: write
/**
* Write a new file.
*
* @param string $path
* @param string $contents
* @param Config $config Config object
*
* @return array|false false on failure file meta data on success
*/
public function write($path, $contents, Config $config)
{
$auth = $this->getAuth();
$token = $auth->uploadToken($this->bucket, $path);
$params = $config->get('params', null);
$mime = $config->get('mime', 'application/octet-stream');
$checkCrc = $config->get('checkCrc', false);
$upload_manager = $this->getUploadManager();
list($ret, $error) = $upload_manager->put($token, $path, $contents, $params, $mime, $checkCrc);
if ($error !== null) {
$this->logQiniuError($error);
return false;
} else {
return $ret;
}
}
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:25,代码来源:QiniuAdapter.php
示例9: writeStream
/**
* {@inheritdoc}
*/
public function writeStream($path, $resource, Config $config)
{
$location = $this->applyPathPrefix($path);
$this->ensureDirectory(dirname($location));
$stream = fopen($location, 'wb+');
if ($stream === false) {
return false;
}
stream_copy_to_stream($resource, $stream);
if (!fclose($stream)) {
return false;
}
if ($visibility = $config->get('visibility')) {
$this->setVisibility($path, $visibility);
}
return compact('path', 'visibility');
}
开发者ID:honeybee,项目名称:honeybee,代码行数:20,代码来源:LocalAdapter.php
示例10: upload
/**
* Upload an object.
*
* @param $path
* @param $body
* @param Config $config
*
* @return array
*/
protected function upload($path, $body, Config $config)
{
$key = $this->applyPathPrefix($path);
$mimetype = MimeType::detectByFileExtension(pathinfo($path, PATHINFO_EXTENSION));
$config->set('mimetype', $mimetype);
$return = parent::upload($path, $body, $config);
if (function_exists('getimagesizefromstring') && strpos($mimetype, 'image') !== false) {
if (is_resource($body)) {
rewind($body);
$size = getimagesizefromstring(stream_get_contents($body));
} else {
$size = getimagesizefromstring($body);
}
$this->s3Client->copyObject(['Bucket' => $this->bucket, 'CopySource' => $this->bucket . DS . $key, 'ContentType' => $mimetype, 'Metadata' => ['width' => $size[0], 'height' => $size[1]], 'MetadataDirective' => 'REPLACE', 'Key' => $key]);
}
return $return;
}
开发者ID:uaudio,项目名称:magento-filestorage,代码行数:26,代码来源:AwsS3Adapter.php
示例11: writeStream
/**
* {@inheritdoc}
*/
public function writeStream($path, $resource, Config $config)
{
$location = $this->applyPathPrefix($path);
$this->ensureDirectory(dirname($location));
if (!($stream = fopen($location, 'w'))) {
return false;
}
while (!feof($resource)) {
fwrite($stream, fread($resource, 1024), 1024);
}
if (!fclose($stream)) {
return false;
}
if ($visibility = $config->get('visibility')) {
$this->setVisibility($path, $visibility);
}
return compact('path', 'visibility');
}
开发者ID:wasay,项目名称:GaeSupportL5,代码行数:21,代码来源:GaeAdapter.php
示例12: testGet
public function testGet()
{
$config = new Config();
$this->assertFalse($config->has('setting'));
$this->assertNull($config->get('setting'));
$config->set('setting', 'value');
$this->assertEquals('value', $config->get('setting'));
$fallback = new Config(['fallback_setting' => 'fallback_value']);
$config->setFallback($fallback);
$this->assertEquals('fallback_value', $config->get('fallback_setting'));
}
开发者ID:mechiko,项目名称:staff-october,代码行数:11,代码来源:ConfigTests.php
示例13: write
/**
* Write a new file.
*
* @param string $path
* @param string $contents
* @param Config $config Config object
*
* @return array|false false on failure file meta data on success
*/
public function write($path, $contents, Config $config)
{
if ($config->has('ttl') && !$config->has('expirationType')) {
$config->set('expirationType', self::EXPIRE_IN_SECONDS);
}
$args = array_merge([$path, $contents], array_filter([$config->get('expirationType'), $config->get('ttl'), $config->get('setFlag')], function ($value) {
return !is_null($value);
}));
if (!call_user_func_array([$this->client, 'set'], $args)) {
return false;
}
return compact('path', 'contents');
}
开发者ID:patrickrose,项目名称:flysystem-redis,代码行数:22,代码来源:RedisAdapter.php
示例14: writeStream
/**
* Write a new file using a stream.
*
* @param string $path
* @param resource $resource
* @param Config $config Config object
*
* @return array|false false on failure file meta data on success
*/
public function writeStream($path, $resource, Config $config)
{
$model = $this->findByLocation($path);
if (null === $model) {
$model = $this->model->create(['location' => $path]);
}
while (!feof($resource)) {
$model->content .= fread($resource, 1024);
}
if ($visibility = $config->get('visibility')) {
$model->visibility = $visibility === true;
}
try {
$model->save();
} catch (\Exception $e) {
return false;
}
return compact('path', 'visibility');
}
开发者ID:rokde,项目名称:flysystem-local-database-adapter,代码行数:28,代码来源:LocalDatabaseAdapter.php
示例15: createDir
/**
* {@inheritdoc}
*/
public function createDir($dirname, Config $config)
{
$headers = $config->get('headers', []);
$headers['Content-Type'] = 'application/directory';
$extendedConfig = (new Config())->setFallback($config);
$extendedConfig->set('headers', $headers);
return $this->write($dirname, '', $extendedConfig);
}
开发者ID:jiiis,项目名称:ptn,代码行数:11,代码来源:RackspaceAdapter.php
示例16: getOptionsFromConfig
/**
* Get options from the config.
*
* @param Config $config
*
* @return array
*/
protected function getOptionsFromConfig(Config $config)
{
$options = $this->options;
if ($visibility = $config->get('visibility')) {
// For local reference
$options['visibility'] = $visibility;
// For external reference
$options['ACL'] = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? 'public-read' : 'private';
}
if ($mimetype = $config->get('mimetype')) {
// For local reference
$options['mimetype'] = $mimetype;
// For external reference
$options['ContentType'] = $mimetype;
}
foreach (static::$metaOptions as $option) {
if (!$config->has($option)) {
continue;
}
$options[$option] = $config->get($option);
}
return $options;
}
开发者ID:janhartigan,项目名称:flysystem-aws-s3-v3,代码行数:30,代码来源:AwsS3Adapter.php
示例17: prepareConfig
/**
* Convert a config array to a Config object with the correct fallback.
*
* @param array $config
*
* @return Config
*/
protected function prepareConfig(array $config)
{
$config = new Config($config);
$config->setFallback($this->config);
return $config;
}
开发者ID:RyanThompson,项目名称:flysystem,代码行数:13,代码来源:Filesystem.php
示例18: kvPut
protected function kvPut($path, $contents, Config $config, $file = null)
{
$addOrSet = is_null($file) ? 'set' : 'add';
$file['contents'] = $contents;
$file['timestamp'] = time();
$file['size'] = Util::contentSize($contents);
if ($visibility = $config->get('visibility')) {
$file['visibility'] = $visibility;
}
if ($this->client->{$addOrSet}($path, $file)) {
return $file + compact('path');
}
return false;
}
开发者ID:litp,项目名称:flysystem-sae,代码行数:14,代码来源:KvdbAdapter.php
示例19: doMirror
private function doMirror($originDir, $targetDir, Flysystem\Config $config)
{
if ($config->get('delete', true) && $this->doHas($targetDir)) {
$it = $this->getIterator($targetDir, \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($it as $handler) {
/** @var HandlerInterface $handler */
$origin = str_replace($targetDir, $originDir, $handler->getPath());
if (!$this->doHas($origin)) {
if ($handler->isDir()) {
$this->doDeleteDir($handler->getPath());
} else {
$this->doDelete($handler->getPath());
}
}
}
}
if ($this->doHas($originDir)) {
$this->doCreateDir($targetDir, $config);
}
$it = $this->getIterator($originDir, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($it as $handler) {
$target = str_replace($originDir, $targetDir, $handler->getPath());
if ($handler->isDir()) {
$this->doCreateDir($target, $config);
} else {
$this->doCopy($handler->getPath(), $target, $config->get('override'));
}
}
}
开发者ID:pkdevboxy,项目名称:filesystem,代码行数:29,代码来源:Filesystem.php
示例20: update
/**
* Update a file
*
* @param string $path
* @param string $contents
* @param mixed $config Config object or visibility setting
* @return array|bool
*/
public function update($path, $contents, Config $config)
{
$path = $this->clean($path);
if (!$this->has($path)) {
throw new \Exception('File not found' . $path);
}
$postData = ["file" => '/' . $path, 'content' => $contents, '_method' => 'put'];
$this->request('put_content', $path, $postData);
$size = strlen($contents);
$mimetype = $this->getMimetype($path);
if ($visibility = $config->get('visibility')) {
$result['visibility'] = $visibility;
$this->setVisibility($path, $visibility);
}
return compact('path', 'size', 'contents', 'mimetype');
}
开发者ID:modelframework,项目名称:modelframework,代码行数:24,代码来源:Pydio.php
注:本文中的League\Flysystem\Config类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论