コード例 #1
0
 /**
  * Get a response for download the given email attachment
  *
  * @Route("/attachment/{id}", name="oro_email_attachment", requirements={"id"="\d+"})
  * @AclAncestor("oro_email_view")
  */
 public function attachmentAction(EmailAttachment $entity)
 {
     $response = new Response();
     $response->headers->set('Content-Type', $entity->getContentType());
     $response->headers->set('Content-Disposition', sprintf('attachment; filename="%s"', $entity->getFileName()));
     $response->headers->set('Pragma', 'no-cache');
     $response->headers->set('Expires', '0');
     $content = ContentDecoder::decode($entity->getContent()->getValue(), $entity->getContent()->getContentTransferEncoding());
     $response->setContent($content);
     return $response;
 }
コード例 #2
0
ファイル: Processor.php プロジェクト: northdakota/platform
 /**
  * @param \Swift_Message $message
  * @param EmailModel     $model
  */
 protected function addAttachments(\Swift_Message $message, EmailModel $model)
 {
     /** @var EmailAttachmentModel $emailAttachmentModel */
     foreach ($model->getAttachments() as $emailAttachmentModel) {
         $attachment = $emailAttachmentModel->getEmailAttachment();
         $swiftAttachment = new \Swift_Attachment(ContentDecoder::decode($attachment->getContent()->getContent(), $attachment->getContent()->getContentTransferEncoding()), $attachment->getFileName(), $attachment->getContentType());
         $message->attach($swiftAttachment);
     }
 }
コード例 #3
0
ファイル: Value.php プロジェクト: Maksold/platform
 /**
  * Gets the decoded value
  *
  * @param string $toEncoding The type of encoding that the content is being converted to.
  *                           Defaults to 'UTF-8'
  * @return string
  */
 public function getDecodedValue($toEncoding = 'UTF-8')
 {
     return ContentDecoder::decode($this->value, null, $this->encoding, $toEncoding);
 }
コード例 #4
0
 /**
  * @param EmailAttachment $emailAttachment
  *
  * @return File|null
  */
 protected function copyEmailAttachmentToFileSystem(EmailAttachment $emailAttachment)
 {
     $file = new File();
     $file->setExtension($emailAttachment->getExtension());
     $file->setOriginalFilename($emailAttachment->getFileName());
     $file->setMimeType($emailAttachment->getContentType());
     $file->setFilename(uniqid() . '.' . $file->getExtension());
     $content = ContentDecoder::decode($emailAttachment->getContent()->getContent(), $emailAttachment->getContent()->getContentTransferEncoding());
     $this->filesystem->write($file->getFilename(), $content);
     $f = new ComponentFile($this->getAttachmentFullPath($file->getFilename()));
     $file->setFile($f);
     $file->setFileSize($f->getSize());
     $file->setUploaded(false);
     $file->setOwner($this->securityFacadeLink->getService()->getLoggedUser());
     return $file;
 }
コード例 #5
0
ファイル: Content.php プロジェクト: Maksold/platform
 /**
  * Gets the decoded content data
  *
  * @param string $toEncoding The type of encoding that the content is being converted to.
  *                           Defaults to 'UTF-8'
  * @return string
  */
 public function getDecodedContent($toEncoding = 'UTF-8')
 {
     return ContentDecoder::decode($this->content, $this->contentTransferEncoding, $this->encoding, $toEncoding);
 }