Laravel Stapler - AWS S3上载失败,没有消息

时间:2014-08-19 07:46:40

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

使用laravel-stapler,我的laravel雄辩模型试图保存S3的附件。 S3配置已经设置好并且正由laravel-stapler包正确选取。

这是我雄辩的模特:

use Codesleeve\Stapler\ORM\StaplerableInterface;
use Codesleeve\Stapler\ORM\EloquentTrait;

class SwiftDocument extends Eloquent implements StaplerableInterface{

use Illuminate\Database\Eloquent\SoftDeletingTrait;

use EloquentTrait;

protected $table = "swift_document";

protected $guarded = array('id');

protected $fillable = ["document_file_name","document_file_size","document_content_type","document_updated_at","user_id"];

public $timestamps = true;

protected $dates = ['deleted_at'];

public function __construct(array $attributes = array())
{
    // Define an attachment named 'document' that stores files locally.
    $this->hasAttachedFile('document', [
        'storage' => 's3',
        'url' => '/upload/:attachment/:id/:filename',
        'default_url' => '/defaults/:style/missing.png',
        'keep_old_files' => true            
    ]);

    parent::__construct($attributes);
}

/*
 * Event Observers
 */

public static function boot() {
    parent:: boot();

    /*
     * Set User Id on Save
     */
    static::saving(function($model){
        $model->user_id = Sentry::getUser()->id;
    });

    static::bootStapler();

}   
....

保存附件后,将抛出以下错误(以JSON格式,因为它是ajax调用):

{"错误" {"类型":" AWS \ S3 \异常\ InvalidArgumentException""消息":&#34 ;""文件":" / extvol / WWW / HTML / scottswift / HTTP /供应商/ AWS / AWS-SDK-PHP / SRC / AWS /普通/异常/ NamespaceExceptionFactory。 PHP""线" 91}}

正如您所看到的消息部分空白

对此有何想法?

1 个答案:

答案 0 :(得分:1)

ACL' S3 Bucket配置的键值设置错误。

阅读aws documentation found here后,上传就像魅力一样。