vendredi 28 août 2015

cant get aws sdk (php) to work

guys ive looked through dozens of threads and even asked aws for help but still nothing, you guys are my last hope :P

Im using laravel 5.1 and trying to download a file from a secure s3 bucket, here's my code, can you figure out what im missing?

public function documentation($filename)
{

    $s3 = new Aws\S3\S3Client([
        'version' => 'latest',
        'region'  => 'eu-west-1'
    ]);

    $object = $s3->getObject([
        'Bucket' => 'chkoutpnt',
        'Key' => 'product_documents/'.$filename
    ]);


    header("Content-Disposition: attachment; filename=\"$filename\"");
    header("Content-Length: {$object['ContentLength']}");
    header("Content-Type: {$object['ContentType']}");

    $out = fopen('php://output', 'w');

    stream_copy_to_stream($object['Body'], $out);
}

i think its laravels fault cause i get this when i click on the link

The webpage at http://ift.tt/1WXcfuE might be temporarily down or it may have moved permanently to a new web address.

the link is a laravel link to action(controller@funtion)




Aucun commentaire:

Enregistrer un commentaire