/** * 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; }
/** * 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'); }
/** * {@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); }
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')); }
/** * 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; }
/** * Get options from the config. * * @param Config $config * @return array */ protected function getOptionsFromConfig(Config $config) { $options = $this->options; foreach (static::$mappingOptions as $option => $ossOption) { if (!$config->has($option)) { continue; } $options[$ossOption] = $config->get($option); } return $options; }
/** * Retrieve options from a Config instance. * * @param Config $config * * @return array */ protected function getOptionsFromConfig(Config $config) { $options = []; foreach (static::$metaOptions as $option) { if (!$config->has($option)) { continue; } $options[$option] = $config->get($option); } if ($mimetype = $config->get('mimetype')) { // For local reference $options['mimetype'] = $mimetype; // For external reference $options['ContentType'] = $mimetype; } return $options; }
/** * Retrieve options from a Config instance. * * @param Config $config * * @return CreateBlobOptions */ protected function getOptionsFromConfig(Config $config) { $options = new CreateBlobOptions(); foreach (static::$metaOptions as $option) { if (!$config->has($option)) { continue; } call_user_func([$options, "set{$option}"], $config->get($option)); } if ($mimetype = $config->get('mimetype')) { $options->setContentType($mimetype); } return $options; }