amazon-web-servicesdockeramazon-s3canvas-lms

How to add a prefix or folders in a bucket for multiple source for Canvas LMS


I have found out how to store files from local to an Amazon S3 Bucket but I have other problems.

In my bucket when I upload a file from my Canvas LMS website to the S3 bucket the files stored at

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

but I have three "folders" in my bucket:

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

and I need to configure the yml files to tell every image where to save its files

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

And so on.

I use docker do build images, how can I do it? Should I change the bucket name in amazon_s3.yml from

bucket_name: Mybucket

to

bucket_name: Mybucket/AAA 

I tried it, but nothing happens just errors.


UPDATE:

I know how to add it in file_store.yml so I use this configuration to save files from CANVAS LMS to dir-A directory :

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

what I need it's to change this path_prefix for every docker-compose to tell every organization where to save files in aws s3 for example :

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/ 

So like I said above, I know how to save files in directory ,but I used by Dockerfile by building images with amazon_s3.yml and file_store.yml

And now I need to change just the path_prefix for every organization is that possible and how please?


Solution

  • I found the solution; So to make edit path_prefix in file_store.yml for every docker-compose

    I add this ENV

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

    and in docker-compose.yml I add HELLO_VARIABLE to environment like:

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

    and work perfectly when I upload now file to my canvas LMS platform the files stored at

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