karthzDIGI
karthzDIGI

Reputation: 403

How to copy a file from a website to amazon bucket using zend service amazon?

I need to copy a resource from a website to my s3-bucket. For example an image like this 'http://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png' I need to copy this to a folder in my s3-bucket. Is this possible using Zend_Service_Amazon?

Upvotes: 0

Views: 120

Answers (1)

Samy
Samy

Reputation: 632

You have to use stream wrappers. I haven't dealt with Image files but hope it will work .

      $s3 = new Zend_Service_Amazon_S3($my_aws_key, $my_aws_secret_key);
      $s5="s".rand();
      $s3->registerStreamWrapper($s5);
       //$bucketname- your bucket name
      mkdir($s5."://".$bucketname);
        //$path - where you want to store your file including bucketname
      $s1=$s5."://".$path;
      $filedata = file_get_contents('yourimage url');
      file_put_contents($s1, $fildata);

Upvotes: 1

Related Questions