示例#1
0
 public function __construct(array $config)
 {
     if (empty($config['bucket'])) {
         throw new Storage_Service_Exception('No bucket specified');
     }
     $this->_bucket = $config['bucket'];
     $this->_internalService = new Zend_Service_Amazon_S3($config['accessKey'], $config['secretKey'], $config['region']);
     if (!empty($config['path'])) {
         $this->_path = $config['path'];
     } else {
         $this->_path = 'public';
     }
     if (!empty($config['baseUrl'])) {
         $this->_baseUrl = $config['baseUrl'];
         unset($config['baseUrl']);
         // Add http:// if no protocol
         if (false === strpos($this->_baseUrl, '://')) {
             $this->_baseUrl = 'http://' . $this->_baseUrl;
         }
     }
     // Should we register the stream wrapper?
     $this->_streamWrapperName = 's3' . (int) @$config['service_id'];
     $this->_internalService->registerStreamWrapper($this->_streamWrapperName);
     parent::__construct($config);
 }
示例#2
0
 public function indexAction()
 {
     $s3 = new Zend_Service_Amazon_S3('AKIAJ5HTOSBB7ITPA6VQ', 'n8ZjV8xz/k/FxBGhrVduYlSXVFFmep7aZJ/NOsoj');
     $this->view->buckets = $s3->getBuckets();
     $bucketName = 'vaultman';
     $ret = $s3->getObjectsByBucket($bucketName);
     $this->view->objects = $ret;
     $this->view->form = new Mybase_Form_Files();
     $formData = $this->getRequest()->getPost();
     if ($this->_request->isPost()) {
         $s3->registerStreamWrapper("s3");
         //file_put_contents("s3://".$bucketName."/".$_FILES['img']['name'], fopen($_FILES['img']['tmp_name'], 'r'));
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->setDestination("s3://" . $bucketName . "/");
         //$adapter->receive();
     }
 }