Используя laravel-stapler, моя модель laravel eloquent пытается сохранить вложение в 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 \ Exception \ InvalidArgumentException", "сообщение": "", "файл": "/ extvol / www / html / scottswift / http / vendor / aws / aws-sdk -php / src / Aws / Common / Exception / NamespaceExceptionFactory.php "," строка ": 91}}

Как видите, часть сообщения пуста .

Есть мысли по этому поводу?

0
Mysteryos 19 Авг 2014 в 11:46

1 ответ

Лучший ответ

Неправильно задано значение ключа ACL для конфигурации S3 Bucket.

После прочтения документации aws, найденной здесь, загрузка работала как шарм.

1
Mysteryos 19 Авг 2014 в 13:42