/**
  * @param \Shockwavemk\Mail\Base\Model\Mail\Attachment $attachment
  */
 protected function _processDownload($attachment)
 {
     /** @var \Magento\Framework\App\ResponseInterface $response */
     $response = $this->getResponse();
     $response->setHttpResponseCode(200)->setHeader('Pragma', 'public', true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Content-type', $attachment->getFileType(), true);
     $this->getResponse()->setHeader('Content-Disposition', $attachment->getDisposition() . '; filename=' . basename($attachment->getFileName()));
     $this->getResponse()->clearBody();
     $this->getResponse()->sendHeaders();
     echo $attachment->getBinary();
 }
 /**
  * Save an attachment binary to a file in host temp folder
  *
  * @param \Shockwavemk\Mail\Base\Model\Mail\Attachment $attachment
  * @return int $id
  * @throws \Magento\Framework\Exception\FileSystemException
  * @throws \Magento\Framework\Exception\MailException
  * @throws \Exception
  */
 public function saveAttachment($attachment)
 {
     $binaryData = $attachment->getBinary();
     /** @var \Shockwavemk\Mail\Base\Model\Mail $mail */
     $mail = $attachment->getMail();
     $folderPath = $this->getMailFolderPathById($mail->getId()) . DIRECTORY_SEPARATOR . self::ATTACHMENT_PATH;
     // create a folder for message if needed
     $this->createFolder($folderPath);
     // try to store message to filesystem
     $filePath = $this->storeFile($binaryData, $this->getMailFolderPathById($mail->getId()) . DIRECTORY_SEPARATOR . self::ATTACHMENT_PATH . DIRECTORY_SEPARATOR . basename($attachment->getFilePath()));
     $attachment->setFilePath($filePath);
 }
 /**
  * Save an attachment binary to a file in host temp folder
  *
  * @param \Shockwavemk\Mail\Base\Model\Mail\Attachment $attachment
  * @return int $id
  */
 public function saveAttachment($attachment)
 {
     $binaryData = $attachment->getBinary();
     $mail = $attachment->getMail();
     $folderPath = $this->getMailFolderPath($mail) . DIRECTORY_SEPARATOR . self::ATTACHMENT_PATH;
     // create a folder for message if needed
     $this->prepareFolderPath($folderPath);
     // try to store message to filesystem
     return $this->storeFile($binaryData, $this->getMailLocalFilePath($mail, DIRECTORY_SEPARATOR . self::ATTACHMENT_PATH . $attachment->getFilePath()));
 }
예제 #4
0
 public function getDownloadUrl(\Shockwavemk\Mail\Base\Model\Mail\Attachment $attachment)
 {
     return $this->getUrl('customer/mail/attachment', array('id' => base64_encode($this->getMail()->getId()), 'path' => base64_encode($attachment->getFilePath())));
 }