Is this really the version you are looking for? Kentico Xperience 8 Documentation is no longer updated. Use the switcher in the header to choose your product version.
You can utilize the Amazon S3 storage service for storing your website files even though the website is hosted on-premise, on your own server.
File name case
Unlike standard Windows file systems, the Amazon S3 storage is case-sensitive. To ensure consistent behavior, Kentico automatically converts all file and folder names to lower case when processing files on Amazon S3.
Make sure that you have your Amazon S3 account set up and and that you have created at least one bucket.
Add the following key into the appSettings section of your project's web.config.
<add key="CMSExternalStorageName" value="amazon" />Add the following key to specifiy the bucket that you want to use to store files. Replace the value with the name of the bucket.
<add key="CMSAmazonBucketName" value="YourBucketName" />Specify the ID of your Amazon access key by inserting the following key:
<add key="CMSAmazonAccessKeyID" value="YourKey" />Specify the Amazon access key by adding the following key:
<add key="CMSAmazonAccessKey" value="YourSecret" />After you save your web.config, Kentico starts storing files in the specified Amazon S3 bucket.
Additional website settings
When configuring this type of storage, keep in mind that the website itself must be configured to store files in the file system rather than in the database only. In Settings -> System -> Files enable the Store files in file system option.
It is also recommended to enable Redirect files to disk in Settings -> System -> Performance. This means that files will be requested from the Amazon S3 account rather than from the database (if possible).
You can configure the following optional settings:
Key | Description | Sample Value |
|---|---|---|
CMSAmazonTempPath | Path to a local directory that the system uses to store temporary files. If you do not specify a value, the provider use the default operating system temporary directory. | HTML |
CMSAmazonCachePath | Path to a local directory where the provider stores cached files. If you do not use this setting, the system creates a directory in the default operating system temporary directory. | HTML |
CMSAmazonEndPoint | Allows you to change the default endpoint, for example when you want to use CloudFront CDN. The default endpoint address is http://<yourbucketname>.s3.amazonaws.com (opens in a new tab) | HTML |
CMSAmazonPublicAccess | Specifies whether files uploaded to Amazon S3 through Kentico are accessible for public users. The default value is true if you specify an endpoint. If no endpoint is specified, the default value is false. | HTML |
By default, the system stores files in a single bucket. However, the built-in Amazon S3 storage provider allows you to map sections of the file system to different buckets.
using CMS.IO;
using CMS.Base;
[CustomStorage]
public partial class CMSModuleLoader
{
private class CustomStorageAttribute : CMSLoaderAttribute
{
/// <summary>
/// The system executes the Init method of the CMSModuleLoader attributes when the application starts.
/// </summary>
public override void Init()
{
// Creates a new StorageProvider instance
AbstractStorageProvider mediaProvider = new StorageProvider("Amazon", "CMS.AmazonStorage");
// Specifies the target bucket
mediaProvider.CustomRootPath = "mymediabucket";
// Makes the bucket publicly accessible
mediaProvider.PublicExternalFolderObject = true;
// Maps a directory to the provider
StorageHelper.MapStoragePath("~/MySite/Media/", mediaProvider);
}
}
}