Return the MIME multipart representation of this MediaEntry.

@return string
@throws Zend_Gdata_App_IOException
173414
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.');
        }
    }
691475
protected function getPostBody()
    {
        $data = '';
        if (count($this->_postFiles) > 0) {
            $boundary = md5($this->_rawUrl . microtime());
            foreach ($this->_postFields as $k => $v) {
                $data .= '--' . $boundary . Client::CRLF . 'Content-Disposition: form-data; name="' . $k . '"'
                    . Client::CRLF . Client::CRLF . $v . Client::CRLF;
            }
            foreach ($this->_postFiles as $k => $v) {
                $ext = strtolower(substr($v[0], strrpos($v[0], '.') + 1));
                $type = isset(self::$_mimes[$ext]) ? self::$_mimes[$ext] : 'application/octet-stream';
                $data .= '--' . $boundary . Client::CRLF . 'Content-Disposition: form-data; name="' . $k . '"; filename="' . $v[0] . '"'
                    . Client::CRLF . 'Content-Type: ' . $type . Client::CRLF . 'Content-Transfer-Encoding: binary'
                    . Client::CRLF . Client::CRLF . $v[1] . Client::CRLF;
            }
            $data .= '--' . $boundary . '--' . Client::CRLF;
            $this->setHeader('content-type', 'multipart/form-data; boundary=' . $boundary);
        } else {
            if (count($this->_postFields) > 0) {
                foreach ($this->_postFields as $k => $v) {
                    $data .= '&' . rawurlencode($k) . '=' . rawurlencode($v);
                }
                $data = substr($data, 1);
                $this->setHeader('content-type', 'application/x-www-form-urlencoded');
            }
        }
        return $data;
    }
1347498
public function getMime()
    {
        if (!$this->mime)
        {
            $type = FileType::getFromFile($this->getFullPath());
            $this->mime = $type->getMimeType();
        }
        return $this->mime;
    }
604220
public function mimeType() {
        // if the type is known, return it
        if (!is_null($this->type)) {
            return $this->type;
        }
        
        // make sure the file is available to check
        $this->downloadFile();
        
        // get the file info
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        
        // get the MIME type of the file 
        $mime= finfo_file($finfo, $this->downloadFilePath());
        
        // clode the file info resource
        finfo_close($finfo);
        
        // store and return the file MIME type
        return $this->type = $mime;
    }
122741
private function formatBody()
    {
        $body = [];

        if (!empty($this->files)) {
            $data = [];

            if(!is_null($this->serialized_payload)) {
                collect($this->serialized_payload)->each(function($value, $key) use (&$data) {
                    $data[] = [
                        'name'     => $key,
                        'contents' => $value,
                    ];
                });
            }

            $body['multipart'] = array_merge($this->files, $data);

            return $body;
        }

        if ($this->content_type == Mime::JSON) {
            $body['json'] = $this->serialized_payload;
        } elseif ($this->method == Http::GET) {
            $body['query'] = $this->serialized_payload;
        } elseif (is_array($this->serialized_payload)) {
            $body['form_params'] = $this->serialized_payload;
        } else {
            $body['body'] = $this->serialized_payload;
        }

        return $body;
    }
1196419
public function getMimeType()
    {
        if (empty($this->mimeType)) {
            $finfo = new \finfo(FILEINFO_MIME_TYPE);
            $this->mimeType = $finfo->buffer($this->getBinaryContent());
            if (empty($this->mimeType)) {
                throw new ImageException('Cannot determine MIME type', ImageException::CANNOT_DETERMINE_MIME_TYPE);
            }
        }
        return $this->mimeType;
    }
515180
private function build_alternative_multipart() {
    $boundary =  "ba".md5(uniqid(time()));

    $multipart =  "Content-Type: multipart/alternative; boundary = $boundary\n\n";

    for($i = sizeof($this->altparts)-1; $i >= 0; $i--)
    {
      $multipart .=  "\n--$boundary\n".$this->build_message($this->altparts[$i]);
    }
    return $multipart.=  "\n--"."$boundary"."--\n";
  }
496771
protected function getContenType(): string
	{
		return $this->contentType ?? ($this->fileSystem->info($this->filePath)->getMimeType() ?? 'application/octet-stream');
	}
1192563
public function getBinaryContent()
    {
        if ($this->binaryContentDirty) {
            $mimeType = $this->getMimeType();
            // we consider that 
            $options = array_replace($this->ephemeralImagineOptions, $this->imagineOptions);
            $binaryContent = $this->getImagineImage()->get(
                    self::get_type_from_mime_type($mimeType),
                $options);
            $this->setBinaryContent($binaryContent, $mimeType);
        }
        return $this->binaryContent;
    }
1031550
public function getMime()
    {
        $mimes = $this->getMimes();
        $ext = strtolower($this->getExtension());

        if (isset($mimes[ $ext ])) {
            return $mimes[ $ext ];
        }

        return false;
    }
636550
public function getFile()
    {
        if (!$this->hasGetParameter('uri')) {
            throw new \common_exception_Error('invalid media identifier');
        }
        $uri = urldecode($this->getGetParameter('uri'));

        $mediaSource = new MediaSource(array());
        $fileInfo = $mediaSource->getFileInfo($uri);

        $fileManagement = $this->getServiceLocator()->get(FileManagement::SERVICE_ID);
        $stream = $fileManagement->getFileStream($fileInfo['link']);
        if ($fileInfo['mime'] === 'application/qti+xml') {
            $this->response = $this->getPsrResponse()->withBody($stream);
        } elseif ($this->hasGetParameter('xml')) {
            $this->returnJson(htmlentities((string)$stream));
        } else {
            $this->setContentHeader($fileInfo['mime']);
            $this->response = $this->getPsrResponse()->withBody($stream);
        }
    }
1341095
public function getMime()
    {
        if ($this->metadata->isFile()) {
            $mimes = $this->package->config('mime.types');
            foreach ($mimes as $mime => $mimeValues) {
                $key = collect($mimeValues)->search(function ($mimeValue) {
                    return preg_match($mimeValue, $this->metadata->getMimeType());
                });

                if ($key !== false) {
                    return $mime;
                }
            }

            return 'file';
        }

        return 'dir';
    }
982566
public function toString()
	{
		if ( $this->test() )
		{
			if ( class_exists('\\Imagick') )
				$m = $this->img;
			else
			{
				ob_start();
				\call_user_func('image'.$this->ext2,$this->img);
				$m = ob_get_contents();
				ob_end_clean();
			}
			return 'data:image/'.$this->ext.';base64,'.base64_encode($m);
		}
	}
540837
public function getDisposition()
    {
        /** @noinspection IsEmptyFunctionUsageInspection */
        if (empty($this->getData('disposition'))) {
            $this->setData(
                'disposition',
                Zend_Mime::DISPOSITION_ATTACHMENT
            );
        }

        return $this->getData('disposition');
    }
505399
public function getHeaderContent()
    {
        $headerContent = '';
        $sender = $this->getSender();
        if (!empty($sender)) {
            $headerContent .= 'From: ' . $sender . PHP_EOL;
        }
        $reply = $this->getReply();
        if (!empty($reply)) {
            $headerContent .= 'Reply-to: ' . $reply . PHP_EOL;
        }
        $recipientCc = $this->getRecipientCc();
        if (!empty($recipientCc)) {
            $headerContent .= 'Cc: ' . $recipientCc . PHP_EOL;
        }
        $recipientBcc = $this->getRecipientBcc();
        if (!empty($recipientBcc)) {
            $headerContent .= 'Bcc: ' . $recipientBcc . PHP_EOL;
        }
        if (!empty($this->mailer)) {
            $headerContent .= 'X-Mailer: ' . $this->mailer . PHP_EOL;
        }
        $headerContent .= 'MIME-Version: 1.0' . PHP_EOL;
        if (!empty($this->attachmentList)) {
            $contentType = 'multipart/mixed';
        } else {
            $contentType = 'multipart/alternative';
        }
        $headerContent .= 'Content-Type: ' . $contentType . '; boundary="' . $this->boundary . '"';
        $headerContent .= PHP_EOL . PHP_EOL;
        return $headerContent;
    }
1050555
public function getMimeType()
    {
        if ($this->isUploaded() && $this->mime_type === null) {
            $temp_file_name = $this->getTempFileName();
            if (file_exists($temp_file_name)) {
                if (extension_loaded('fileinfo')) {
                    // Use the fileinfo extension if available.
                    $finfo = $this->getFinfo();
                    $this->mime_type = explode(
                        ';',
                        $finfo->file($temp_file_name)
                    )[0];
                } elseif (function_exists('mime_content_type')) {
                    // Fall back to mime_content_type() if available.
                    $this->mime_type = mime_content_type($temp_file_name);
                }

                // No mime-detection functions, or mime-detection function
                // failed to detect the type. Default to
                // 'application/octet-stream'. Relying on HTTP headers could
                // be a security problem so we never fall back to that option.
                if ($this->mime_type == '') {
                    $this->mime_type = 'application/octet-stream';
                }
            } else {
                $this->mime_type = $this->file['type'];
            }
        }

        return $this->mime_type;
    }
170788
public function getObject()
	{
		if( !empty( $this->_embedded ) )
		{
			$parts = array();

			if( $this->_html != null )
			{
				$part = new Zend_Mime_Part( $this->_html );

				$part->charset = $this->_object->getCharset();
				$part->encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE;
				$part->disposition = Zend_Mime::DISPOSITION_INLINE;
				$part->type = Zend_Mime::TYPE_HTML;

				$parts = array( $part );
			}

			$msg = new Zend_Mime_Message();
			$msg->setParts( array_merge( $parts, $this->_embedded ) );

			// create html body (text and maybe embedded), modified afterwards to set it to multipart/related
			$this->_object->setBodyHtml( $msg->generateMessage() );

			$related = $this->_object->getBodyHtml();
			$related->type = Zend_Mime::MULTIPART_RELATED;
			$related->encoding = Zend_Mime::ENCODING_8BIT;
			$related->boundary = $msg->getMime()->boundary();
			$related->disposition = null;
			$related->charset = null;
		}
		else if( $this->_html != null )
		{
			$this->_object->setBodyHtml( $this->_html );
		}

		return $this->_object;
	}