Welcome Guest, Not a member yet? Register   Sign In
Settingup AWS S3 and Codeigniter
#1

I need to use Amazon S3 with CI3, so my plan is making a library called AmazonS3 where i will have basic methods like up() delete() tokenize() just for example.
I have installed S3 using composer inside the application/s3 directory.
**Code of my Library: **

PHP Code:
<?php 
defined
('BASEPATH') OR exit('u no here!');

use 
Aws\S3\S3Client;

class 
AmazonS3 {

private 
$s3;
private 
$bucket;

function 
__construct()
{
    
$this->bucket 'images.secret.com';

    require 
'application/s3/vendor/autoload.php';

    
$this->s3 S3Client::factory([
        
'key' => 'super-key---',
        
'secret' => 'thats-a-long-string'
    
]);
}

public function 
up()
{
    
$this->s3->putObject([
        
'Bucket' => $this->bucket,
        
'Key' => 'images/test.jpg',
        
'Body' => fopen('application/img/test.jpg''rb'),
        
'ACL' => 'public-read'
    
]);
}



This up() method is just a testing purpose, the way i called this from another controller is looks like:

PHP Code:
$this->load->library('amazons3');
    
$this->amazons3->up(); 

WHich gives me few ton's of error. What i am missing? [posted on stackoverflow as well]
Reply
#2

(02-11-2015, 11:32 AM)rakibtg Wrote: I need to use Amazon S3 with CI3, so my plan is making a library called AmazonS3 where i will have basic methods like up() delete() tokenize() just for example.
I have installed S3 using composer inside the application/s3 directory.
**Code of my Library: **


PHP Code:
<?php 
defined
('BASEPATH') OR exit('u no here!');

use 
Aws\S3\S3Client;

class 
AmazonS3 {

private 
$s3;
private 
$bucket;

function 
__construct()
{
 
   $this->bucket 'images.secret.com';

 
   require 'application/s3/vendor/autoload.php';

 
   $this->s3 S3Client::factory([
 
       'key' => 'super-key---',
 
       'secret' => 'thats-a-long-string'
 
   ]);
}

public function 
up()
{
 
   $this->s3->putObject([
 
       'Bucket' => $this->bucket,
 
       'Key' => 'images/test.jpg',
 
       'Body' => fopen('application/img/test.jpg''rb'),
 
       'ACL' => 'public-read'
 
   ]);
}



This up() method is just a testing purpose, the way i called this from another controller is looks like:


PHP Code:
   $this->load->library('amazons3');
 
   $this->amazons3->up(); 

WHich gives me few ton's of error. What i am missing? [posted on stackoverflow as well]

You should probably update this as closed since you figured out the issue.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB