We are trying to integrate AWS S3 in our Kentico 10 application.I followed this link:https://docs.xperience.io/k10/custom-development/working-with-physical-files-using-the-api/configuring-file-system-providers/configuring-amazon-s3#ConfiguringAmazonS3-MedialibrarynotesI created following module in App_Code =@ CMSModules =@ AWSS3 =@ AWSS3Module.csHere is the code of AWSS3Module.csusing CMS;
using CMS.DataEngine;
using CMS.EventLog;
using CMS.IO;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
/*
Make sure following entries exists in web.config =@ @appSettings@
@add key=@CMSAmazonBucketName@ value=@@ /@
@add key=@CMSAmazonAccessKeyID@ value=@@ /@
@add key=@CMSAmazonAccessKey@ value=@@ /@
@add key=@CMSAmazonPublicAccess@ value=@true@ /@
@add key=@CMSAmazonEndPoint@ value=@@ /@
*/
[assembly: RegisterModule(typeof(AWSS3Module))]
/// @summary@
/// Summary description for AWSS3Module
/// @/summary@
public class AWSS3Module: Module
{
public AWSS3Module(): base(@AWSS3Module@)
{
//
// TODO: Add constructor logic here
//
}
// Initializes the module. Called when the application starts.
protected override void OnInit()
{
base.OnInit();
// Assigns a handler to the Insert.After event for OfficeInfo objects
EventLogProvider.LogInformation(@AWSS3 module@, @OnInit@, @This code is running@);
// Creates a new StorageProvider instance
AbstractStorageProvider mediaProvider = new StorageProvider(@Amazon@, @CMS.AmazonStorage@);
// Specifies the target bucket
mediaProvider.CustomRootPath = ConfigurationManager.AppSettings[@CMSAmazonBucketName@];
// Makes the bucket publicly accessible
mediaProvider.PublicExternalFolderObject = true;
// Maps a directory to the provider
StorageHelper.MapStoragePath(@~/Sitename/@, mediaProvider);
}
}
I read in one of the post that only new files will be synced. I tried adding few files in the media folder but nothing added in bucket.There are no errors in logs. Also, I can see the module is loaded in the logs.Bucket policy seems to be correct or I couldn't find issues in logs.What am I doing wrong?Also, if a file is uploaded, how can I get the S3 URL for that file?
↧