Welcome Guest, Not a member yet? Register   Sign In
upload file to amazon S3 and CI upload class
#1

[eluser]tim peterson[/eluser]
i'm trying to upload a file to my Amazon S3 bucket. My friend had this working on our site in the past but a year later its busted and I can't figure out what's wrong. We are using the S3 PHP library developed by: Geoff gaudreault (@neurofuzzy) http://www.neurofuzzy.net/2006/08/26/ama...ss-update/

This library looks pretty straightforward to me, really it looks like there is one key function: putObject().

Unfortunately, I'm not even getting out of the gate. I'm getting the following error message: Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

here's my codeigniter PHP for my upload form action:

Code:
function s3(){

    $config['upload_path'] = $_SERVER["DOCUMENT_ROOT"].'/temp/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '1000000';
    $config['max_width']  = '1024000';
    $config['max_height']  = '768000';

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

    if ( ! $this->upload->do_upload())
    {
        $error = array('error' => $this->upload->display_errors());

        print_r($error);
        echo 'failure';
    }
    else
    {
       $data = array('upload_data' => $this->upload->data());
        $fn = $data['file_name'];
        $type = substr($fn, strrpos($fn, '.') + 1);

    $this->load->library('s3');
    $temp_file_path = $_SERVER["DOCUMENT_ROOT"]."/temp/" . $data['file_name'];
    $contents = read_file($temp_file_path); // will this blow up or timeout for large files?!
    $newFileName = uniqid().".".substr($temp_file_path, strrpos($temp_file_path, '.') + 1);
     $contentPath = "mysite.com/Images";

    $this->s3->putObject($newFileName, $contents, $contentPath, 'private', $type);
    echo 'success';
    }
}

does anyone have any thoughts?

thanks, tim




Theme © iAndrew 2016 - Forum software by © MyBB