示例#1
0
 /**
  * Write a file
  *
  * @param   string  $path
  * @param   string  $contents
  * @param   mixed   $config
  * @return  array   file metadata
  */
 public function write($path, $contents, $config = null)
 {
     $config = Util::ensureConfig($config);
     $options = $this->getOptions($path, array('Body' => $contents, 'ContentType' => Util::contentMimetype($contents), 'ContentLength' => Util::contentSize($contents)));
     if ($visibility = $config->get('visibility')) {
         $options['ACL'] = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? 'public-read' : 'private';
     }
     $this->client->putObject($options);
     if ($visibility) {
         $options['visibility'] = $visibility;
     }
     return $this->normalizeObject($options);
 }
示例#2
0
文件: Zip.php 项目: luoshulin/falcon
 public function getMimetype($path)
 {
     if (!($data = $this->read($path))) {
         return false;
     }
     $data['mimetype'] = Util::contentMimetype($data['contents']);
     return $data;
 }
示例#3
0
 /**
  * Retrieve the mimetype of an object
  *
  * @param   string       $path
  * @return  null|string  mimetype or null on failure
  */
 public function getMimetype($path)
 {
     if (isset($this->cache[$path]['mimetype'])) {
         return $this->cache[$path]['mimetype'];
     }
     if (!($contents = $this->read($path))) {
         return false;
     }
     $mimetype = Util::contentMimetype($contents);
     $this->cache[$path]['mimetype'] = $mimetype;
     return $mimetype;
 }
示例#4
0
 /**
  * Update a file
  *
  * @param $path
  * @param $contents
  * @return array|bool
  */
 public function update($path, $contents)
 {
     $location = $this->prefix($path);
     if (($size = file_put_contents($location, $contents, LOCK_EX)) === false) {
         return false;
     }
     return array('path' => $path, 'size' => $size, 'contents' => $contents, 'mimetype' => Util::contentMimetype($contents));
 }