【问题标题】:AWS Package error in Laravel 4.2Laravel 4.2 中的 AWS 包错误
【发布时间】:2018-10-26 20:59:10
【问题描述】:

好吧,我在我的应用程序中使用 Laravel 4.2 版,但是我在使用 AWS Package 时遇到了一些问题:/

我用这个包https://github.com/aws/aws-sdk-php-laravel

我完成了 README.md 中描述的所有操作,但是当我尝试将图像发送到 S3 时收到此错误

从实例配置文件元数据服务器检索凭据时出错。当您不在 Amazon EC2 内部运行时,您必须在创建客户端时在“key”和“secret”选项中提供您的 AWS 访问密钥 ID 和秘密访问密钥,或者提供实例化的 Aws\Common\Credentials\CredentialsInterface 对象。 ([curl] 7: 连接到 169.254.169.254:80 失败;没有路由到主机 [url] 169.254.169.254/latest/meta-data/iam/security-credentials/)

我把包放在我的 composer.json 中

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

然后我发送命令

作曲家更新

我放入文件夹 app/config/packages/aws/aws-sdk-php-laravel/config.php

<?php

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

并尝试调用方法

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

但没有任何作用:(

有人知道怎么回事吗?

【问题讨论】:

  • 这个问题发生在我身上,发现已关闭:github.com/aws/aws-sdk-php-laravel/issues/22 - 我通过删除 aws 供应商并重新安装来解决此问题。
  • 所以,我在重新安装供应商后出现了一些更奇怪的行为。问题又出现了。我似乎遇到的问题是我有一个自定义配置文件“aws.php”,它与包配置文件冲突(也在 github 上的 #22 问题上注明)
  • 您可以使用帮助程序包建立连接。前任。 github.com/CodeSleeve/laravel-stapler

标签: php amazon-web-services laravel-4 amazon-ec2 amazon-s3


【解决方案1】:

我强烈建议将这些用于组合包:

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",

在你的代码中:

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!

【讨论】:

    猜你喜欢
    • 2023-04-04
    • 1970-01-01
    • 2018-07-01
    • 2015-12-29
    • 2014-05-10
    • 2016-08-21
    • 2015-11-26
    • 1970-01-01
    • 2015-12-22
    相关资源
    最近更新 更多