I have a project hosted in Amazon EC2 Ireland (Ubuntu).
I develope with CodeIgniter, and I want to use S3 to storage files.
I’ve used three or four specific libraries for use S3 with CodeIgniter, and none have worked. I tried official AWS SDK for PHP, and the compatibility test is OK, but the sample doesn’t work. I think that the problem is access to S3.
I create in S3 Management three buckets, two in Ireland and one in US standard, and I can access files by browser, S3 Organizer (S3Fox) and Cyberduck. But I don’t access with my project.
Anyone can help me?
Sorry for my bad English…
Controller amazona.php:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Amazona extends CI_Controller {
var $bucket = 'cubito';
function __construct()
{
parent::__construct();
$this->load->library('S3');
}
function index()
{
/* $data['files'] = $this->s3->getBucket('cubito'); */
$data['texto'] = "prueba";
$this->load->view('amazona', $data);
}
}
?>
view amazona.php:
<html>
<head>
<title>prueba</title>
</head>
<body>
<a href="http://cubito.s3.amazonaws.com/imagen.jpg">imagen</a>
<img src="http://cubito.s3.amazonaws.com/imagen.jpg" />
<p><?php echo($texto); ?></p>
<p><?php echo($this->s3->listBuckets()); ?></p>
</body>
</html>
I added a bucket policy, but still doesn’t work:
{
"Version": "2008-10-17",
"Id": "Policy1351373775750",
"Statement": [
{
"Sid": "Stmt1351373767997",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::cubito",
"arn:aws:s3:::cubito/*"
]
}
]
}
I did it!!
I change the var $endpoint in the s3 library.
The original:
The change:
With my first accesskey and secretkey it run!!!
Thank you everyone and sorry for my bad English.
¡¡¡Gracias!!!