コード例 #1
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;
 }
コード例 #2
0
 /**
  * Copy attachment file object
  *
  * @param File $file
  *
  * @return File
  */
 public function copyAttachmentFile(File $file)
 {
     $fileCopy = clone $file;
     $fileCopy->setFilename($this->generateFileName($file->getExtension()));
     $sourceStream = $this->filesystem->createStream($file->getFilename());
     $this->copyStreamToStorage($sourceStream, $fileCopy->getFilename());
     return $fileCopy;
 }
コード例 #3
0
 /**
  * Get filetype icon
  *
  * @param File $entity
  * @return string
  */
 public function getAttachmentIconClass(File $entity)
 {
     if (isset($this->fileIcons[$entity->getExtension()])) {
         return $this->fileIcons[$entity->getExtension()];
     }
     return $this->fileIcons['default'];
 }