Giter Club home page Giter Club logo

codeigniter-s3's Introduction

Amazon S3 Library for CodeIgniter

Easily integrate your CI applications to Amazon’s Simple Storage Solution with this library.

This library is (hardly) a port of Donovan Schönknecht’s S3 PHP Class.

Setup

  1. Edit config/s3.php with your appropriate settings
  2. Copy config and library files to your CI installation

Class Methods

For more detailed information about the required parameters and returns check the S3.php file.

Objects:

  • copyObject
  • deleteObject
  • getObject
  • getObjectInfo
  • inputFile
  • inputResource
  • putObject
  • getAuthenticatedURL

Buckets:

  • listBuckets
  • getBucket
  • putBucket
  • deleteBucket
  • getBucketLocation
  • getBucketLogging
  • setBucketLogging
  • disableBucketLogging
  • getHttpUploadPostParams

Access Control Policies:

  • getAccessControlPolicy
  • setAccessControlPolicy

CloudFront:

  • listDistributions
  • createDistribution
  • getDistribution
  • updateDistribution
  • deleteDistribution

Legacy methods:

  • putObjectFile
  • putObjectString

Example Usage


  // Load Library
  $this->load->library('s3');
  
  // Create a Bucket
  var_dump($this->s3->putBucket('My-Bucket', $this->s3->ACL_PUBLIC_READ));
  
  // List Buckets
  var_dump($this->s3->listBuckets());

References

codeigniter-s3's People

Contributors

andyshinn avatar daverogers avatar fernandosavio avatar gothick avatar kevinsmith avatar panman avatar psugand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter-s3's Issues

File upload on S3 Bucket

Hello Prashant,

We just copied your files and paste into our CI project with AWS keys and bucket name but its not working.

System library, S3 Library and make config in config.php

Can you please help me!

Thanks

Call to undefined function curl_init()

Hi,

I am trying to call $this->s3->listBuckets() but I keep geeting this error:
A PHP Error was encountered

Severity: Error

Message: Call to undefined function curl_init()

Filename: libraries/S3.php

Line Number: 1365

Can you help me with this?

Access Denied Error for deleteObject

Hi,

I am recieving an error when I try to delete an object and I have the correct permissions, I think.

Here is the exact message: Message: S3::deleteObject(): [AccessDenied] Access Denied

Any idea why I am getting this message?

REDUCED_REDUNDANCY

How can we set REDUCED_REDUNDANCY on the file uploads?
Can't get it to work with your code...

Object Size error

Get contents for a bucket returning wrong object size for large objects (tried it with 8.2GB object but returned size as 2GB). Temporary fix was to type cast size as a float in the getBucket function

Amazon Server Side Encryption

$input = $this->s3->inputFile($pathToFile);

$this->s3->putObject($input, S3BUCKET, "data/form.json" , S3::ACL_PUBLIC_READ,array("x-amz-server-side​-encryption"=>"AES256"));

Doing this to encrypt data on Amazon S3 bucket, I receive:

Message: S3::putObject(): [SignatureDoesNotMatch] The request signature we calculated does not match the signature you provided. Check your key and signing method.

When i change my code to:

$this->s3->putObject($input, S3BUCKET, "data/form.json" , S3::ACL_PUBLIC_READ);

Everything is back to normal. Any idea?

Problem when Upload file any connection is established

Hi team! I need help when I try to upload files from a post.

I have this code inside a "for" bucle:

for ($i = 0; $i < count($_FILES['pictures']['name']); $i++){
$path_parts = pathinfo($_FILES['pictures']['name'][$i]);
$image_path = $path_parts['filename'].$path_parts['extension'];

      $uri =  $image_path;
      $file = $_FILES['pictures']['tmp_name'][$i];
      $input = S3::inputFile($file);
      if (S3::putObject($input, $bucket, $uri, S3::ACL_PUBLIC_READ)) {
        echo "File uploaded.";
        } else {
            echo "Failed to upload file." . $uri . $bucket . $input;
        }
    }

But not works. I have configured my keys but I think that the problems comes maybe to not set region of the bucle?

Please any help is appreciated. Thank you!

deleteObject() returns true but object seems not deleted

Hi i'm using this wonderfull library and i'm really happy with it.

I just think i got a problem with the deleteObject() method.

I have a bucket called "webapp".
Then all my links looks like "www.s3.amazon.com/webapp/123/photos/file.jpg" so i run $this->s3->deleteObject("webapp","www.s3.amazon.com/webapp/123"); and it returns TRUE without any errors.

But if i browse the link by browser the files still be in there, so the object is not deleted.

Have you any clue please?

Thanks a lot!

Dying in $rest->getResponse() in putObject()

This runs perfect for me locally, but on my server it's dying inside of the $rest->getResponse() function between

public function getResponse(){

        echo 'in getResponse'.br(1);

        var_dump($this);

        $query = '';
        if (sizeof($this->parameters) > 0){
            $query = substr($this->uri, -1) !== '?' ? '?' : '&';
            foreach ($this->parameters as $var => $value)
                if ($value == null || $value == '')
                    $query .= $var . '&';
                // Parameters should be encoded (thanks Sean O'Dea)
                else
                    $query .= $var . '=' . rawurlencode($value) . '&';
            $query = substr($query, 0, -1);
            $this->uri .= $query;

            if (array_key_exists('acl', $this->parameters) ||
                    array_key_exists('location', $this->parameters) ||
                    array_key_exists('torrent', $this->parameters) ||
                    array_key_exists('logging', $this->parameters))
                $this->resource .= $query;
        }

        $url = ((S3::$use_ssl && extension_loaded('openssl')) ?
                        'https://' : 'http://') . $this->headers['Host'] . $this->uri;
        // var_dump($this->bucket, $this->uri, $this->resource, $url);
        // Basic setup
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_USERAGENT, 'S3/php');

        echo '1'.br(1);
....
....
}

Why would it work locally but die here on the server?

Get Session token for mobile devices

Hello
This is not an Issue, I'm using your library its working fine. One thing, I need session token which we need to pass to iOS developer using that they will upload files directly to S3 using AWS iOS SDK. Can you please tell me how can i generate session token using your library.

bucketExists

Hello,
how can we check if bucket exist or not ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.