3
votes

Well, I use Laravel version 4.2 in my application, but I have some problems with AWS Package :/

I use this package https://github.com/aws/aws-sdk-php-laravel

I did everything that was described in README.md, but when I try send a image to S3 I receive this error

Error retrieving credentials from the instance profile metadata server. When you are not running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in the "key" and "secret" options when creating a client or provide an instantiated Aws\Common\Credentials\CredentialsInterface object. ([curl] 7: Failed connect to 169.254.169.254:80; No route to host [url] 169.254.169.254/latest/meta-data/iam/security-credentials/)

I put the package in my composer.json

"aws/aws-sdk-php-laravel": "1.*"

And i send the command

composer update

I put in folder app/config/packages/aws/aws-sdk-php-laravel/config.php

<?php

return array(
    'key'         => '[key]',
    'secret'      => '[secret]',
    'region'      => 'us-east-1',
    'config_file' => null,
);

And try call the method

AWS::get('s3')->putObject(array(
            'Bucket'     => ['bucket'],
            'Key'        => ['key'],
            'SourceFile' => ['source']
        ));

But nothing work :(

Anyone know what's going on?

1
This issue happened to me to, and found the closed: github.com/aws/aws-sdk-php-laravel/issues/22 - I fixed this by removing the aws vendor and reinstall it. - jvv
So, I had some more strange behavior after reinstalling the vendor. The issue re-appeared. The problem I seemed to have was that I had a custom configuration file 'aws.php', which conflicted with the package configuration file (noted on the #22 issue on github as well) - jvv
You could make a connection using a helper package. Ex. github.com/CodeSleeve/laravel-stapler - olgundutkan

1 Answers

1
votes

I highly recommend using these to packages combined:

https://github.com/GrahamCampbell/Laravel-Flysystem/tree/v1.0.0 https://github.com/thephpleague/flysystem-aws-s3-v2

composer.json:

"graham-campbell/flysystem": "~1.0",
"league/flysystem-aws-s3-v2": "~1.0",

And in your code:

use GrahamCampbell\Flysystem\Facades\Flysystem;
// you can alias this in app/config/app.php if you like

Flysystem::put('hi.txt', 'foo');
// we're done here - how easy was that, it just works!