Esempio n. 1
0
 public function write(Storage_Model_File $model, $data)
 {
     // Write data
     $path = $this->getScheme()->generate($model->toArray());
     try {
         $this->_mkdir(dirname(APPLICATION_PATH . DS . $path));
         $this->_write(APPLICATION_PATH . DS . $path, $data);
         @chmod($path, 0777);
     } catch (Exception $e) {
         @unlink(APPLICATION_PATH . DS . $path);
         throw $e;
     }
     return $path;
 }
Esempio n. 2
0
 /**
  * Creates a new file from data rather than an existing file
  *
  * @param Storage_Model_DbRow_File $model The file for operation
  * @param string $data
  */
 public function write(Storage_Model_File $model, $data)
 {
     $path = $this->getScheme()->generate($model->toArray());
     // Prefix path with bucket?
     //$path = $this->_bucket . '/' . $path;
     // Copy file
     try {
         $return = $this->_internalService->putObject($this->_bucket . '/' . $path, $data, array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ, 'Cache-Control' => 'max-age=864000, public'));
         if (!$return) {
             throw new Storage_Service_Exception('Unable to write file.');
         }
     } catch (Exception $e) {
         throw $e;
     }
     return $path;
 }
Esempio n. 3
0
 /**
  * Creates a new file from data rather than an existing file
  *
  * @param Storage_Model_DbRow_File $model The file for operation
  * @param string $data
  */
 public function write(Storage_Model_File $model, $data)
 {
     $path = $this->getScheme()->generate($model->toArray());
     // Copy file
     try {
         $this->getVfs()->putContents($path, $data);
     } catch (Exception $e) {
         throw $e;
     }
     return $path;
 }
Esempio n. 4
0
 public function temporary(Storage_Model_File $model)
 {
     $tmp_file = APPLICATION_PATH . '/public/temporary/storage/' . $model->getIdentity() . '.' . $model->extension;
     $this->_mkdir(dirname($tmp_file));
     if (!($handle = fopen($tmp_file, 'wb'))) {
         throw new Storage_Service_Exception('Unable to write to temporary file');
     }
     $i = 0;
     while ($string = $this->_read($model, $i++)) {
         fwrite($handle, $string);
     }
     return $tmp_file;
 }