getCompressionMimeType() 공개 정적인 메소드

Reads the file, detects the compression MIME type, closes the file and returns the MIME type
public static getCompressionMimeType ( resource $file ) : string
$file resource the file handle
리턴 string the MIME type for compression, or 'none'
예제 #1
0
/**
 * Detects what compression the file uses
 *
 * @param string $filepath filename to check
 *
 * @return string MIME type of compression, none for none
 * @access public
 */
function PMA_detectCompression($filepath)
{
    $file = @fopen($filepath, 'rb');
    if (!$file) {
        return false;
    }
    return PMA\libraries\Util::getCompressionMimeType($file);
}
예제 #2
0
 /**
  * Detects what compression the file uses
  *
  * @todo    move file read part into readChunk() or getChunk()
  * @todo    add support for compression plugins
  * @access  protected
  * @return  string|false false on error, otherwise string MIME type of
  *                       compression, none for none
  */
 protected function detectCompression()
 {
     // suppress warnings from being displayed, but not from being logged
     // f.e. any file access outside of open_basedir will issue a warning
     ob_start();
     $file = fopen($this->getName(), 'rb');
     ob_end_clean();
     if (!$file) {
         $this->_error_message = Message::error(__('File could not be read!'));
         return false;
     }
     /**
     * @todo
     * get registered plugins for file compression
     
             foreach (PMA_getPlugins($type = 'compression') as $plugin) {
        if ($plugin['classname']::canHandle($this->getName())) {
            $this->setCompressionPlugin($plugin);
            break;
        }
             }
     */
     $this->_compression = Util::getCompressionMimeType($file);
     return $this->_compression;
 }