How do I download a file with php and the Amazon S3 sdk?

后端 未结 6 1947
不思量自难忘°
不思量自难忘° 2020-12-15 21:01

I\'m trying to make it so that my script will show test.jpg in an Amazon S3 bucket through php. Here\'s what I have so far:

require_once(\'library/AWS/sdk.cl         


        
6条回答
  •  天命终不由人
    2020-12-15 21:47

    Got it to work by echo'ing out the content-type header before echo'ing the $object body.

    $objInfo = $s3->get_object_headers('my_bucket', 'test.jpg');
    $obj = $s3->get_object('my_bucket', 'test.jpg');
    
    header('Content-type: ' . $objInfo->header['_info']['content_type']);
    echo $obj->body;
    

提交回复
热议问题