By default, on-premise installations of Cloud CMS are configured with a GridFS (`gridfs`) Binary Storage Provider. This allows Cloud CMS to read and write binary files (such as attachments) to GridFS.
At some point, as your installation grows, you may want change this.
Suppose you wanted to move your binary files into S3 and use S3 as a Binary Storage Provider for Cloud CMS.
To do so, we recommend the following steps:
1. Make a backup of your Cloud CMS database.
2. Create an S3 bucket and IAM user who has appropriate read/write access to that bucket.
3. Configure the API to use the "S3 with Grid FS fallback and file caching" Binary Storage Provider.
4. Set the org.gitana.platform.services.binary.storage.provider.s3gridfs.cache
flag to false
.
This provider will tell Cloud CMS to first check an S3 bucket for any read or write operations. If it can't find something in S3, it will use GridFS. After you restart the Cloud CMS API containers, your API should effectively work the same as before since your S3 bucket is empty.
Now you will need to write some code.
Your code should connect to MongoDB and query for all keys of all GridFS files in your repository database. We recommend using a native MongoDB driver but you also may be able to do this using third party tools.
For each file that it finds, it should write that same file to the S3 bucket. The key, content type and byte content should all be identical. We recommend using the native Amazon AWS SDK to achieve this but you may be able to get away with using a third party tool as well.
We recommend doing this with 1 file at first. Copy it to S3 and then remove it from GridFS. And then test it within the Cloud CMS API to verify that it serves from S3. With caching disabled, you should expect the content to serve a bit slower since there is no local caching and it will stream from S3 on each request.
Once that's good, you can start bulk copying stuff as you wish. And you can also delete stuff out of GridFS as it makes sense for you to do so.
To learn more about Binary Storage Providers in Cloud CMS, please see:
https://www.cloudcms.com/documentation/docker/configuration/api-server.html#binary-storage
To learn about the ""S3 with Grid FS fallback and file caching" Binary Storage Provider, please see:
https://www.cloudcms.com/documentation/docker/configuration/api-server.html#s3-with-grid-fs-fallback-and-file-caching