예제 #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;
 }
예제 #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());
     // Copy file
     try {
         $this->getVfs()->putContents($path, $data);
     } catch (Exception $e) {
         throw $e;
     }
     return $path;
 }
예제 #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());
     // 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;
 }