本文整理汇总了PHP中League\Flysystem\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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');
}
示例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;
}
示例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');
}
示例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'));
}
示例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');
}
示例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');
}
示例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);
}