从 Mall Plugin October CMS 将文件上传到 AWS S3

问题描述 投票:0回答:1

我需要在 October CMS 之前将 Mall Plugin 的图片产品上传到 AWS S3 上

我已设置

cms.php

'默认' => 's3',

我的

filesystem.php

'default' => 's3',

  

      /*
        |--------------------------------------------------------------------------
        | Filesystem Disks
        |--------------------------------------------------------------------------
        |
        | Here you may configure as many filesystem "disks" as you wish, and you
        | may even configure multiple disks of the same driver. Defaults have
        | been setup for each driver as an example of the required options.
        |
        | Supported Drivers: "local", "ftp", "sftp", "s3"
        |
        */
    
        'disks' => [
    
            'local' => [
                'driver' => 'local',
                'root' => storage_path('app'),
                'throw' => false,
            ],
    
            'uploads' => [
                'driver' => 's3',
                'key' => env('AWS_ACCESS_KEY_ID'),
                'secret' => env('AWS_SECRET_ACCESS_KEY'),
                'region' => env('AWS_DEFAULT_REGION'),
                'bucket' => env('AWS_BUCKET'),
                'url' => env('AWS_URL'),
                'endpoint' => env('AWS_ENDPOINT'),
                'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
                'throw' => false,
            ],
    
            'media' => [
                'driver' => 's3',
                'key' => env('AWS_ACCESS_KEY_ID'),
                'secret' => env('AWS_SECRET_ACCESS_KEY'),
                'region' => env('AWS_DEFAULT_REGION'),
                'bucket' => env('AWS_BUCKET'),
                'url' => env('AWS_URL'),
                'endpoint' => env('AWS_ENDPOINT'),
                'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
                'throw' => false,
            ],
            
            'resources' => [
                'driver' => 'local',
                'root' => storage_path('app/resources'),
                'url' => '/storage/app/resources',
                'visibility' => 'public',
                'throw' => false,
            ],
    
            's3' => [
                'driver' => 's3',
                'key' => env('AWS_ACCESS_KEY_ID'),
                'secret' => env('AWS_SECRET_ACCESS_KEY'),
                'region' => env('AWS_DEFAULT_REGION'),
                'bucket' => env('AWS_BUCKET'),
                'url' => env('AWS_URL'),
                'endpoint' => env('AWS_ENDPOINT'),
                'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
                'visibility' => 'public',
                'throw' => false,
            ]        
    
        ],

我对 AWS 存储桶的政策:

 "Version": "2008-10-17",
        "Statement": [
            {
                "Sid": "AllowPublicRead",
                "Effect": "Allow",
                "Principal": "*",
                "Action": "s3:*",
                "Resource": "arn:aws:s3:::MYBUCKET/*"
            }
        ]

所以,我不知道当我上传有关 Mall Plugin 的图片时,AWS S3 上没有上传,但仍然使用 fileupload.js

如何设置商城插件使用S3?

谢谢

amazon-s3 octobercms octobercms-plugins octobercms-backend
1个回答
0
投票

问题不在于商城插件,如果插件在存储设置为本地时将图像上传到上传文件夹,那么当存储设置为 s3 时它必须工作。

您必须检查以下事项。

=> 确认必须安装 Driver Plugin

=> 如果 aws 存储桶上传和媒体目录不存在,则创建并公开它们

我使用的是Ocotber CMS 2.0,这里需要修改两个文件。

  1. 系统.php
  2. 文件系统.php

system.php 应该是什么样子:

// [your_aws_path] = exampledomain.com.s3.amazonaws.com

'storage' => [

  'uploads' => [
    'disk'   => 's3',
    'folder' => 'uploads',
    'path'   => '[your_aws_path]/uploads',
  ],

'media' => [
    'disk'   => 's3',
    'folder' => 'media',
    //'path'   => '/storage/app/media',
    'path'   => '[your_aws_path]/media',
 ],

 'resources' => [
    'disk'   => 's3',
    'folder' => 'resources',
    //'path'   => '/storage/app/resources',
    'path'   => '[your_aws_path]/resources',
  ],

],

filesystems.php 应该是什么样子:

设置

'default' => 's3'

'disks' => [

    'local' => [
        'driver' => 's3',
        'root' => storage_path('app'),
        'url' => '/storage/app',
    ],

    's3' => [
        'driver' => 's3',
        'key' => [AWS_ACCESS_KEY_ID],
        'secret' => [AWS_SECRET_ACCESS_KEY],
        'region' => [AWS_DEFAULT_REGION],
        'bucket' => , [AWS_BUCKET]
        'visibility' => 'public',
    ],

    'rackspace' => [
        'driver' => 'rackspace',
        'username' => 'your-username',
        'key' => 'your-key',
        'container' => 'your-container',
        'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/',
        'region' => 'IAD',
    ],

],
© www.soinside.com 2019 - 2024. All rights reserved.