jeudi 6 août 2015

No HTTP Response when direct stream uploading to Amazon S3

I currently have a function that grabs an mp3 file from a remote url, and uploads it to an Amazon S3 bucket.

The function seems to work fine in that the file appears in S3, however I'm concerned that while testing this on my local server using a tunnel (ngrok) the page doesn't seem to be returning any HTTP status.

It does return 200 when I download the file locally first, then upload it. As we're dealing with large audio files, I'm trying to make the first idea work in that it's more efficient (I think).

Is there a way to make the page return a HTTP status code and should I be concerned that it currently doesn't?

Here is the code snippet using the V2 Amazon SDK in PHP

        $config = array('key' => AMAZON_S3_KEY,'secret' => AMAZON_S3_SECRET,'region' => 'us-west-2'); 

        $s3 = Aws::factory($config)->get('s3')->registerStreamWrapper(); 

        $s3->putObject(array(
            'Bucket' => 'mybucket',
            'Key'    => 'filename.mp3',
            'ContentLength' => $size,
            'Body'   => fopen($url, 'r')
        ));




Aucun commentaire:

Enregistrer un commentaire