Ejemplo n.º 1
0
 private function _viewSourceById($id)
 {
     $imageModel = new Model_Image();
     $imageRow = $imageModel->fetchRow($imageModel->getAdapter()->quoteInto("id = ?", $id));
     if (count($imageRow) && isset($imageRow->filename)) {
         $file = new Garp_File('image');
         $url = $file->getUrl($imageRow->filename);
         header("Location: " . $url);
         // @codingStandardsIgnoreStart
         exit;
         // @codingStandardsIgnoreEnd
     }
     throw new Zend_Controller_Action_Exception("Sorry, I can't find the requested image.", 404);
 }
Ejemplo n.º 2
0
 /**
  * Class constructor
  * @param String $fileName The datafile
  * @return Void
  */
 public function __construct($fileName)
 {
     $gf = new Garp_File();
     $fileUrl = $gf->getUrl($fileName);
     $this->_importFile = $fileUrl;
 }
Ejemplo n.º 3
0
 /**
  * Download an uploaded file
  *
  * @return Void
  */
 public function downloadAction()
 {
     $ini = Zend_Registry::get('config');
     $downloadType = $this->getRequest()->getParam('downloadType') ?: Garp_File::TYPE_DOCUMENTS;
     $uploadOrStatic = $this->getRequest()->getParam('uploadOrStatic') ?: 'upload';
     $file = $this->getRequest()->getParam('file');
     if (!$file) {
         throw new Zend_Controller_Action_Exception('Geen bestandsnaam opgegeven.', 404);
     }
     try {
         $fileHandler = new Garp_File($downloadType, $uploadOrStatic);
         $url = $fileHandler->getUrl($file);
         $this->_downloadFile($url);
     } catch (Garp_File_Exception_InvalidType $e) {
         // Just throw a 404, since the error is basically just a wrong URL.
         throw new Zend_Controller_Action_Exception($e->getMessage(), 404);
     }
 }