public function testStreamEncoding() { $testfile = realpath(__FILE__); $original = file_get_contents($testfile); // Test Base64 $fp = fopen($testfile, 'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_BASE64; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(base64_decode($encoded), $original); // test QuotedPrintable $fp = fopen($testfile, 'rb'); $this->assertTrue(is_resource($fp)); $part = new Zend_Mime_Part($fp); $part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE; $fp2 = $part->getEncodedStream(); $this->assertTrue(is_resource($fp2)); $encoded = stream_get_contents($fp2); fclose($fp); $this->assertEquals(quoted_printable_decode($encoded), $original); }
/** * if this was created with a stream, return a filtered stream for * reading the content. very useful for large file attachments. * if $this->_alreadyEncoded is set to true, teh stream will be returned * without further filtering. * * @return stream * @throws Zend_Mime_Exception if not a stream or unable to append filter */ public function getEncodedStream() { if (!$this->_isStream) { require_once 'Zend/Mime/Exception.php'; throw new Zend_Mime_Exception('Attempt to get a stream from a string part'); } if ($this->_alreadyEncoded) { return $this->_content; } return parent::getEncodedStream(); }