當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Util::guessMimeType方法代碼示例

本文整理匯總了PHP中League\Flysystem\Util::guessMimeType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Util::guessMimeType方法的具體用法?PHP Util::guessMimeType怎麽用?PHP Util::guessMimeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在League\Flysystem\Util的用法示例。


在下文中一共展示了Util::guessMimeType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 /**
  * {@inheritdoc}
  */
 public function update($path, $contents, Config $config)
 {
     $location = $this->applyPathPrefix($path);
     $mimetype = Util::guessMimeType($path, $contents);
     if (($size = file_put_contents($location, $contents)) === false) {
         return false;
     }
     return compact('path', 'size', 'contents', 'mimetype');
 }
開發者ID:njohns-pica9,項目名稱:flysystem-vfs,代碼行數:12,代碼來源:VfsAdapter.php

示例2: 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)
 {
     list($ret, $err) = Qiniu_RS_Put($this->getClient(), $this->bucket, $path, $contents, null);
     if ($err !== null) {
         return false;
     }
     $mimetype = Util::guessMimeType($path, $contents);
     return compact('mimetype', 'path');
 }
開發者ID:callmez,項目名稱:yii2-file-system,代碼行數:17,代碼來源:Qiniu.php

示例3: write

 /**
  * 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::guessMimeType($path, $contents), 'ContentLength' => Util::contentSize($contents)), $config);
     $result = $this->client->putObject($options);
     if ($result === false) {
         return false;
     }
     return $this->normalizeObject($options);
 }
開發者ID:xamiro-dev,項目名稱:xamiro,代碼行數:18,代碼來源:AwsS3.php

示例4: 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 = null)
 {
     $tmpFile = tempnam(sys_get_temp_dir(), 'arconnect-static');
     file_put_contents($tmpFile, $contents);
     $file = new \CURLFile($tmpFile, Util::guessMimeType($path, $tmpFile), basename($tmpFile));
     $data = ['slug' => $path, 'file' => $file];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->apiUrl . '/' . $this->application);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_exec($ch);
     $fileInfo = curl_getinfo($ch);
     curl_close($ch);
     unlink($tmpFile);
     if ($fileInfo['http_code'] >= 200 && $fileInfo['http_code'] < 400) {
         $response = ['contents' => $contents, 'type' => $fileInfo['content_type'], 'size' => $fileInfo['size_download'], 'path' => $path];
         return $response;
     }
     return false;
 }
開發者ID:ArDeveloppement,項目名稱:flysystem-ardev-static,代碼行數:29,代碼來源:ArStatic.php

示例5: 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)
 {
     $object = $this->applyPathPrefix($path);
     $options = $this->getOptionsFromConfig($config);
     if (!isset($options[OssClient::OSS_LENGTH])) {
         $options[OssClient::OSS_LENGTH] = Util::contentSize($contents);
     }
     if (!isset($options[OssClient::OSS_CONTENT_TYPE])) {
         $options[OssClient::OSS_CONTENT_TYPE] = Util::guessMimeType($path, $contents);
     }
     try {
         $this->client->putObject($this->bucket, $object, $contents, $options);
     } catch (OssException $e) {
         return false;
     }
     $type = 'file';
     $result = compact('type', 'path', 'contents');
     $result['mimetype'] = $options[OssClient::OSS_CONTENT_TYPE];
     $result['size'] = $options[OssClient::OSS_LENGTH];
     return $result;
 }
開發者ID:apollopy,項目名稱:flysystem-aliyun-oss,代碼行數:29,代碼來源:AliyunOssAdapter.php

示例6: getMetadata

 /**
  * {@inheritdoc}
  */
 public function getMetadata($path)
 {
     $info = $this->getPathInfo($path);
     if (!$this->has($path)) {
         throw new \League\Flysystem\FileNotFoundException("File not found at path: {$info['path']}");
     }
     $metadata = json_decode($this->redis->hget($this->applyPathPrefix($info['dirname']), $info['basename']), TRUE);
     if ($metadata['type'] === 'file') {
         $metadata['contents'] = base64_decode($metadata['contents']);
         $metadata += ['size' => Util::contentSize($metadata['contents']), 'mimetype' => Util::guessMimeType($metadata['path'], $metadata['contents'])];
         unset($metadata['contents']);
     }
     return $metadata;
 }
開發者ID:danhunsaker,項目名稱:flysystem-redis,代碼行數:17,代碼來源:RedisAdapter.php

示例7: getMimeType

 /**
  * Get the mime-type from a given path or content
  *
  * @param string $path
  * @param string|resource $content
  * @return string
  */
 private function getMimeType($path, $content)
 {
     if (is_resource($content)) {
         $meta = stream_get_meta_data($content);
         $ext = pathinfo($meta['uri'], PATHINFO_EXTENSION);
         $map = MimeType::getExtensionToMimeTypeMap();
         if (isset($map[$ext])) {
             return $map[$ext];
         } else {
             return '';
         }
     } else {
         return Util::guessMimeType($path, $content);
     }
 }
開發者ID:joyshion,項目名稱:AliyunOSS,代碼行數:22,代碼來源:RequestBuilder.php

示例8: write

 /**
  * @inheritdoc
  */
 public function write($path, $contents, Config $config)
 {
     $stream = fopen('php://temp', 'w+b');
     fwrite($stream, $contents);
     rewind($stream);
     $result = $this->writeStream($path, $stream, $config);
     fclose($stream);
     if ($result === false) {
         return false;
     }
     $result['contents'] = $contents;
     $result['mimetype'] = Util::guessMimeType($path, $contents);
     return $result;
 }
開發者ID:delboy1978uk,項目名稱:flysystem,代碼行數:17,代碼來源:Ftp.php

示例9: write

 /**
  * @inheritdoc
  */
 public function write($path, $contents, Config $config)
 {
     $result = $this->getClient()->putObject($this->bucket, $path, $contents);
     if ($result !== null) {
         return false;
     }
     $mimetype = Util::guessMimeType($path, $contents);
     return compact('mimetype', 'path');
 }
開發者ID:weyii,項目名稱:yii2-filesystem,代碼行數:12,代碼來源:AliYun.php

示例10: write

 /**
  * Write a file
  *
  * @param   string  $path
  * @param   string  $contents
  * @param   mixed   $config
  * @return  array   file metadata
  */
 public function write($path, $contents, $config = null)
 {
     $mimeType = Util::guessMimeType($path, $contents);
     if (isset($config)) {
         if (isset($config["mimeType"])) {
             $mimeType = $config["mimeType"];
         }
     }
     $config = Util::ensureConfig($config);
     $options = $this->getOptions($path, array('ContentType' => $mimeType, 'ContentLength' => Util::contentSize($contents)), $config);
     $dirname = dirname($path);
     $filename = basename($path);
     if ($this->has($path)) {
         $isUpdate = true;
         $file = $this->service->files->get($path);
     } else {
         $file = new Google_Service_Drive_DriveFile();
         $file->setTitle($filename);
         $file->setMimeType($mimeType);
         if ($dirname != ".") {
             $parent = new Google_Service_Drive_ParentReference();
             $parent->setId($dirname);
             $file->setParents(array($parent));
         }
     }
     if (isset($isUpdate)) {
         $result = $this->service->files->update($file['id'], $file, array('data' => $contents, 'mimeType' => $mimeType, 'uploadType' => "multipart"));
     } else {
         $result = $this->service->files->insert($file, array('data' => $contents, 'mimeType' => $mimeType, 'uploadType' => "multipart"));
     }
     if ($result === false) {
         return false;
     }
     $result['mimeType'] = $mimeType;
     $result['title'] = $filename;
     $result['id'] = $result->getId();
     return $this->normalizeObject($result);
 }
開發者ID:xamiro-dev,項目名稱:xamiro,代碼行數:46,代碼來源:GoogleDrive.php

示例11: write

 /**
  * Write a file
  *
  * @param   string $path
  * @param   string $contents
  * @param   mixed  $config
  *
  * @return  array   file metadata
  */
 public function write($path, $contents, $config = null)
 {
     $options = $this->getOptions($path, array('Body' => $contents, 'ContentType' => Util::guessMimeType($path, $contents), 'ContentLength' => Util::contentSize($contents)), $config = Util::ensureConfig($config));
     return $this->writeObject($options);
 }
開發者ID:limweb,項目名稱:webappservice,代碼行數:14,代碼來源:AwsS3.php

示例12: write

 /**
  * @inheritdoc
  */
 public function write($path, $contents, Config $config)
 {
     $stream = fopen('php://temp', 'w+b');
     fwrite($stream, $contents);
     rewind($stream);
     $result = $this->writeStream($path, $stream, $config);
     is_resource($stream) && fclose($stream);
     // TODO 去掉is_resource判斷
     $result['contents'] = $contents;
     $result['mimetype'] = Util::guessMimeType($path, $contents);
     return $result;
 }
開發者ID:weyii,項目名稱:yii2-filesystem,代碼行數:15,代碼來源:QiNiu.php

示例13: getMimetype

 public function getMimetype($path)
 {
     $mimetype = Util::guessMimeType($path, $this->read($path)['contents']);
     return ['mimetype' => $mimetype, 'path' => $path];
 }
開發者ID:litp,項目名稱:flysystem-sae,代碼行數:5,代碼來源:KvdbAdapter.php

示例14: getMimetype

 /**
  * Get the mimetype of a file.
  *
  * @param string $path
  *
  * @return array|false
  */
 public function getMimetype($path)
 {
     $stream = tmpfile();
     fwrite($stream, $this->client->get($path));
     rewind($stream);
     return ['mimetype' => Util::guessMimeType(stream_get_meta_data($stream)['uri'], stream_get_contents($stream))];
 }
開發者ID:patrickrose,項目名稱:flysystem-redis,代碼行數:14,代碼來源:RedisAdapter.php

示例15: update

 /**
  * {@inheritdoc}
  */
 public function update($path, $contents, Config $config)
 {
     if (!$this->hasFile($path)) {
         return false;
     }
     $this->storage[$path]['contents'] = $contents;
     $this->storage[$path]['timestamp'] = time();
     $this->storage[$path]['size'] = Util::contentSize($contents);
     $this->storage[$path]['mimetype'] = Util::guessMimeType($path, $contents);
     if ($visibility = $config->get('visibility')) {
         $this->setVisibility($path, $visibility);
     }
     return $this->getMetadata($path);
 }
開發者ID:twistor,項目名稱:flysystem-memory-adapter,代碼行數:17,代碼來源:MemoryAdapter.php


注:本文中的League\Flysystem\Util::guessMimeType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。