Пример #1
0
 public function listS3Objects()
 {
     try {
         $client = new S3Client();
         $result = $client->listObjects(array('marker' => $this->get('marker'), 'prefix' => $this->get('prefix'), 'maxkeys' => $this->get('maxkeys') | 100));
         $this->success($result);
     } catch (S3Exception $e) {
         $this->error($e->getMessage());
     } catch (AwsException $e) {
         // This catches the more generic AwsException. You can grab information
         // from the exception using methods of the exception object.
         $this->error(array($e->getAwsRequestId(), $e->getAwsErrorType(), $e->getAwsErrorCode()));
     }
 }
 /**
  * Check that the object exists remotely
  * 
  * @return boolean
  */
 public function exists()
 {
     $exists = $this->s3Service->doesObjectExist($this->bucket, $this->getId());
     return $exists;
 }
Пример #3
0
 /**
  * Use the s3ClientManager to return the S3Client object this class is using.
  * Redirecting all requests for an S3Client through this method
  * allows us to lazy load S3Client instances.
  * 	
  * @return S3Client
  */
 protected function getS3Client()
 {
     return $this->s3ClientManager->getS3Client($this->attachedFile);
 }
Пример #4
0
#!/usr/bin/php

<?php 
require 'vendor/autoload.php';
use Aws\Rds\RdsClient;
$client = RdsClient::factory(array('region' => 'us-east-1', 'version' => 'latest'));
$client2 = S3Client::factory(array('region' => 'us-east-1', 'version' => 'latest'));
$result = $client->describeDBInstances(array('DBInstanceIdentifier' => 'mp1jphdb'));
$endpoint = $result['DBInstances'][0]['Endpoint']['Address'];
echo "begin database";
$link = mysqli_connect($endpoint, "jhedlund", "letmeinplease", "mp1jphdb") or die("Error " . mysqli_error($link));
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
}
$create_table = "CREATE TABLE PERSON\r\n(\r\n    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\r\n    uname VARCHAR(20),\r\n    email VARCHAR(200),\r\n    phone VARCHAR(20),\r\n    filename VARCHAR(255),\r\n    s3rawurl VARCHAR(255),\r\n    s3finishedurl VARCHAR(255),\r\n    state TINYINT(3) CHECK(STATE IN(0,1,2)),\r\n    datetime TIMESTAMP)";
$create_tbl = $link->query($create_table);
if ($create_tbl) {
    echo "Table is created or No error returned.";
} else {
    echo "error!!";
}
$link->close();
 public function delete()
 {
     $result = $this->s3Service->deleteObject(array('Bucket' => $this->bucket, 'Key' => $this->getId()));
     return $result;
 }
Пример #6
0
 /**
  * Upload a new template file
  */
 public function index_post()
 {
     validate_admin();
     $this->load->library('form_validation');
     $this->form_validation->set_rules('name', 'Name', 'trim|required|xss_clean');
     if ($this->form_validation->run() == FALSE) {
         json_error('There was a problem with your submission: ' . validation_errors(' ', ' '));
     } else {
         $config = array('upload_path' => $this->config->item('template_upload_dir'), 'allowed_types' => $this->config->item('screen_upload_types'), 'max_size' => $this->config->item('max_screen_upload_size'), 'encrypt_name' => true);
         /* Handle the file upload */
         $this->load->library('upload', $config);
         if ($this->upload->do_upload('file')) {
             $data = $this->upload->data();
             /* Upload to s3 */
             $client = S3Client::factory(array('credentials' => array('key' => $this->config->item('s3_access_key_id'), 'secret' => $this->config->item('s3_secret')), 'region' => $this->config->item('s3_region'), 'version' => $this->config->item('s3_version')));
             $object = array('Bucket' => $this->config->item('s3_bucket'), 'Key' => $data['file_name'], 'SourceFile' => $data['full_path'], 'ACL' => 'public-read');
             $result = $client->putObject($object);
             if ($result['ObjectURL']) {
                 $insert = array('creator_id' => get_user_id(), 'name' => $this->post('name', TRUE), 'ordering' => $this->Template->get_max_ordering() + 1, 'url' => $data['file_name'], 'file_type' => $data['file_type'], 'file_size' => $data['file_size'], 'image_height' => $data['image_height'], 'image_width' => $data['image_width']);
                 $template = $this->decorate_object($this->Template->load($this->Template->add($insert)));
                 unlink($data['full_path']);
                 /* Handle the download situation */
                 $this->response($template);
             } else {
                 log_message('info', '[File Add] putObject Result: ' . print_r($result, TRUE));
                 return json_error('File Upload to S3 Failed: ', $result);
             }
         } else {
             json_error($this->upload->display_errors());
             exit;
         }
     }
 }
 public function createAwsS3Storage($options = array())
 {
     $client = S3Client::factory();
 }