如何为 Canvas LMS 的多个源在存储桶中添加前缀或文件夹

问题描述

我已了解如何将文件从本地存储到 Amazon S3 存储桶 但我还有其他问题。

在我的存储桶中,当我将文件从 Canvas LMS 网站上传到 S3 存储桶时,文件存储在

s3://Mybucket/account_1/attachemenst/myfile.pdf

但我的存储桶中有三个“文件夹”:

s3://Mybucket/AAA/
s3://Mybucket/BBB/
s3://Mybucket/CCC/

我需要配置 yml 文件来告诉每个图像保存文件的位置

www.AAA.com => [save files at ]=> s3://Mybucket/AAA/
www.BBB.com => [save files at ]=> s3://Mybucket/BBB/ 

等等。

我使用 docker 来构建镜像,我该怎么做?我是否应该更改 amazon_s3.yml 中的存储桶名称

bucket_name: Mybucket

bucket_name: Mybucket/AAA 

我试过了,但没有发生任何错误。


更新:

我知道如何在 file_store.yml 中添加它 所以我使用这个配置将文件从 CANVAS LMS 保存到 dir-A 目录:

development:
   storage: s3
   path_prefix: attachments/dir-A/

我需要为每个 docker-compose 更改此 path_prefix 以告诉每个组织在 aws s3 中保存文件的位置 例如:

Organization A =>  s3://bucket-name/account_1/attachments/dir-A/  
Organization B =>  s3://bucket-name/account_1/attachments/dir-B/  
Organization C =>  s3://bucket-name/account_1/attachments/dir-C/ 

所以就像我上面说的,我知道如何将文件保存在目录中,但是我通过使用 amazon_s3.yml 和 file_store.yml 构建图像被 Dockerfile 使用

现在我只需要更改每个组织的 path_prefix 这可能吗?请问怎么办?

解决方法

我找到了解决办法; 因此,为每个 docker-compose 编辑 file_store.yml 中的 path_prefix

我添加了这个环境

production:
  storage: s3
  path_prefix: attachments/<%= ENV['HELLO_VARIABLE'] %>/

在 docker-compose.yml 中,我将 HELLO_VARIABLE 添加到环境中,例如:

  app: &app
    image: registry/images:1
    environment:
      - HELLO_VARIABLE=dir-A

并且当我现在将文件上传到我的画布 LMS 平台时完美运行 存储在

的文件
https://mybucket.s3.eu-central-1.amazonaws.com/account_1/attachments/dir-A/1/myFile.jpg

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...