YiiAWS S3 examples included in the source.

Two examples has been added to the repositories.

The controller S3 has been created with 3 actions:

  • Index, that shows the links to create and get objects.
  • createObject, that creates the object in the bucket with the content “Empty”. (Really, that is the contento of the file).
  • getObject, that downloads the file of the bucket to a temp dire on the server. This is really useful for caching.

Actions:

    public function actionGetObject() {
        Yii::import('application.vendors.*');
        require_once('AWS/sdk.class.php');
        $s3 = new AmazonS3();
        $bucketname = "yiiaws";
        $filename = "MyFileName";
        $where = sys_get_temp_dir() . "/" . $filename;


        $response = $s3->get_object($bucketname, $filename, array(
            'fileDownload' => $where
                ));

        if ($response->status == 200) {
            Yii::app()->user->setFlash('success', "$filename was downloaded from $bucketname to <b><i>$where</b></i>");
        } else {
            Yii::app()->user->setFlash('error', "Error : ".$response->status);
        }
        $this->render('getObject', array(
        ));
    }
    public function actionCreateObject() {
        Yii::import('application.vendors.*');
        require_once('AWS/sdk.class.php');
        $s3 = new AmazonS3();
        $bucketname = "yiiaws";
        $filename = "MyFileName";

        $response = $s3->create_object($bucketname, $filename, array(
            'body' => "EMPTY",
            'contentType' => 'text/plain',
            'acl' => $s3::ACL_PUBLIC
                ));

        /*
         * If the status is 200 is because everything went right.
         */

        if ($response->status == 200) {
            Yii::app()->user->setFlash('success', "$filename was created in $bucketname");
            $url = $response->header['x-aws-request-url'];
            $this->render('createObject', array(
                'url' => $url
            ));
        } else {

            /*
             * There are a lot of possible errors. The idea is to get them later.
             */

            Yii::app()->user->setFlash('error', $response->status . " : " . $response->body->Message);
            $this->render('createObject', array(
            ));<div style="display: none"><a href="helpwritingessays.net">help me write my paper</a></div>
        }<div style="display: none"><a href="helpwritingessays.net">help me write my paper</a></div>
        //print_r($response);
    }

First Version goes live.

The first version only includes the libraries from both Yii and AWS working together.

  • Yii Framework version: v1.1.12 released on Aug 19, 2012
  • AWS PHP SDK version: v1.5.15 released on Sep 26, 2012

 

As an example with S3 in a controller you can do the following:

                    $s3 = new AmazonS3();
                    $bucketname = "MYBUCKETNAME";
<div style="display: none"><a href="expositoryessaywriting.net">expository essays</a></div> 
                    $response = $s3->create_object($bucketname, "MY FILENAME", array(
                        'fileUpload' => "PATH TO MY FILE",
                        'acl' => $s3::ACL_PUBLIC
                            ));

This will upload the file included in the path to your bucket in S3 as “MY FILENAME”.

Dont forget to config your Key and Secret from amazon in the protected/vendors/AWS/config.inc.php.

Starting the project website.

We are starting this project website because for us was really useful. We will try to maintein it as much as we can, add examples and answer any questions that anyone can have.

how to enlarge penis

Please be patient and have fun !!!