setFilename($filename); } /** * Return the MIME multipart representation of this MediaEntry. * * @return string * @throws Zend_Gdata_App_IOException */ public function encode() { if ($this->getFilename() !== null && is_readable($this->getFilename())) { // Retrieves the file, using the include path $fileHandle = fopen($this->getFilename(), 'r', true); $result = fread($fileHandle, filesize($this->getFilename())); if ($result === false) { #require_once 'Zend/Gdata/App/IOException.php'; throw new Zend_Gdata_App_IOException("Error reading file - " . $this->getFilename() . '. Read failed.'); } fclose($fileHandle); return $result; } else { #require_once 'Zend/Gdata/App/IOException.php'; throw new Zend_Gdata_App_IOException("Error reading file - " . $this->getFilename() . '. File is not readable.'); } } /** * Get the filename associated with this reader. * * @return string */ public function getFilename() { return $this->_filename; } /** * Set the filename which is to be read. * * @param string $value The desired file handle. * @return Zend_Gdata_App_MediaFileSource Provides a fluent interface. */ public function setFilename($value) { $this->_filename = $value; return $this; } /** * The content type for the file attached (example image/png) * * @return string The content type */ public function getContentType() { return $this->_contentType; } /** * Set the content type for the file attached (example image/png) * * @param string $value The content type * @return Zend_Gdata_App_MediaFileSource Provides a fluent interface */ public function setContentType($value) { $this->_contentType = $value; return $this; } /** * Alias for getFilename(). * * @return string */ public function __toString() { return $this->getFilename(); } }