コード例 #1
0
 /**
  * @param \Concrete\Core\Entity\File\File $file
  * @param null|int $rcID
  */
 protected function download(\Concrete\Core\Entity\File\File $file, $rcID = null)
 {
     $filename = $file->getFilename();
     $file->trackDownload($rcID);
     $fsl = $file->getFileStorageLocationObject();
     $configuration = $fsl->getConfigurationObject();
     $fv = $file->getVersion();
     if ($configuration->hasPublicURL()) {
         return \Redirect::url($fv->getURL())->send();
     } else {
         return $fv->forceDownload();
     }
 }
コード例 #2
0
ファイル: Service.php プロジェクト: ppiedaderawnet/concrete5
 /**
  * Add attachment to send with an email.
  *
  * Sample Code:
  * $attachment = $mailHelper->addAttachment($fileObject);
  * $attachment->filename = "CustomFilename";
  * $mailHelper->send();
  *
  * @param \Concrete\Core\Entity\File\File $fob File to attach
  *
  * @return \StdClass Pointer to the attachment
  *
  * @throws \Exception
  */
 public function addAttachment(\Concrete\Core\Entity\File\File $fob)
 {
     // Get file version.
     $fv = $fob->getVersion();
     // Get file data.
     $mimetype = $fv->getMimeType();
     $filename = $fv->getFilename();
     $resource = $fob->getFileResource();
     $content = $resource->read();
     // Create attachment.
     $mp = new MimePart($content);
     $mp->type = $mimetype;
     $mp->disposition = Mime::DISPOSITION_ATTACHMENT;
     $mp->encoding = Mime::ENCODING_BASE64;
     $mp->filename = $filename;
     // Add mimepart to attachments.
     $this->attachments[] = $mp;
 }