Example #1
0
 public function testShouldNeverExceedMaxRecursiveLevel()
 {
     // This file is zipped recursively 20 times
     $zippedTooDeepContents = file_get_contents(GARP_APPLICATION_PATH . self::ZIPPED_TOO_DEEP_FILE);
     $unzipper = new Garp_File_Unzipper($zippedTooDeepContents);
     // Unzipper should just return the original when it notices this
     $this->assertEquals($zippedTooDeepContents, $unzipper->getUnpacked());
 }
Example #2
0
 /**
  * Fetches the file data.
  *
  * @param string $filename
  * @return string
  */
 public function fetch($filename)
 {
     // return fopen($this->getUrl($filename), 'r');
     $this->_initApi();
     $obj = $this->_api->getObject($this->_config['bucket'] . $this->_getUri($filename));
     if ($this->_config['gzip'] && $this->_gzipIsAllowedForFilename($filename)) {
         $unzipper = new Garp_File_Unzipper($obj);
         $obj = $unzipper->getUnpacked();
     }
     return $obj;
 }
Example #3
0
 protected function _attachmentToMimePart($args)
 {
     list($id, $attachment) = $args;
     $obj = file_get_contents($attachment);
     // Check if the attachment is gzipped and act accordingly
     $unzipper = new Garp_File_Unzipper($obj);
     $obj = $unzipper->getUnpacked();
     $finfo = new finfo(FILEINFO_MIME);
     $mime = $finfo->buffer($obj);
     $at = new Zend_Mime_Part($obj);
     $at->id = $id;
     $at->type = $mime;
     /**
      * @todo Allow disposition attachment
      */
     $at->disposition = Zend_Mime::DISPOSITION_INLINE;
     $at->encoding = Zend_Mime::ENCODING_BASE64;
     $at->filename = basename($attachment);
     return $at;
 }