1

我在 Amazon EC2 上生成缩略图时遇到问题。

它在我的本地机器上运行良好,当我将它部署到 Amazon EC2 时出现错误

错误/警告是因为我尝试将缩略图上传到 Amazon S3 并且原始图像上传就好了。

Severity: User Warning
Message:  S3::inputFile(): Unable to open input file: /tmp/file_name_thumb.jpg
Filename: libraries/S3.php
Line Number: 263

我的控制器的代码是

//This is the config for first image
$config['upload_path'] = sys_get_temp_dir(); // I tried switching this to '/tmp';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = '500';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['overwrite'] = TRUE;

$this->load->library('upload', $config);
$this->load->library('image_lib');

//Then I do upload
$data = array('upload_data' => $this->upload->data());

// 2nd Config for resize
$config = array(
   'source_image'   => $data['upload_data']['full_path'], //path of the uploaded image
   'new_image'      => sys_get_temp_dir(), //path to target resize, I tried switching this to '/tmp' also ;
   'create_thumb'   => true,
   'maintain_ratio' => true,
   'width'          => 300,
   'height'         => 300,
   'master_dim'     => 'width',);

$this->image_lib->initialize($config);
$this->image_lib->resize();

// Get the path of thumbnail
$fileTempThumbName = sys_get_temp_dir().'/'.$data['upload_data']['raw_name'].'_thumb'.$data['upload_data']['file_ext']; // I also tried replacing the sys_get_temp_dir() with '/tmp'.

$fileTempThumbName 是我放入的参数

$this->s3->putObject($this->s3->inputFile($fileTempThumbName, false),$bucket,$name,$array(),$array())

我的本地在 OSX 10.8.2 上运行 XAMPP 和 PHP 版本 5.3.1 我的 CodeIgniter 是版本 2.1.3 和Amazon S3 PHP 类 0.4.0

我还有 chmod 777 我的 Amazon EC2 实例上的 tmp 文件夹。

当我检查 tmp 文件夹时,调整大小的图像不存在。

先感谢您。

4

1 回答 1

0

问题是我没有在 Amazon EC2 上安装 GD。

After Installing it, everything works quite well.

于 2013-04-10T06:12:20.337 回答