//common
        private ContentImageQueries GetQueries()
        {
            var settings = AmazonS3Files.AmazonS3Settings.FromConfig();
            IFileStorage storage = new AmazonS3Files.AmazonFileStorage(null, settings);

            var contentImageSettings = new ImageSettings()
            {
                Name = Constants.IMAGE_SETTINGS_NAME_CONTENT,
                TempDeleteAge = TimeSpan.FromDays(1),
                Targets = new List<ImageTargetParameters>()
                {
                    new ImageTargetParameters()
                    {
                        PathCreator = new PathCreator()
                        {
                            UrlBase = storage.GetBaseUrl(),
                            TempRootFolder = Constants.IMAGE_TEMP_FOLDER_CONTENT,
                            TempNameFormat = "{0}{1}.jpeg"
                        }
                    }
                }
            };

            var factory = new ImageSettingsFactory(new List<ImageSettings>() { contentImageSettings });
            return new ContentImageQueries(storage, factory);
        }
        public void GetListTest()
        {
            ICommonLogger logger = new ShoutExceptionLogger();
            AmazonS3Settings settings = AmazonS3Settings.FromConfig();
            AmazonFileStorage target = new AmazonFileStorage(logger, settings);
            string folderPath = "posts-temp";

            QueryResult<List<FileDetails>> filesResult = target.GetList(folderPath).Result;
            Assert.IsFalse(filesResult.HasExceptions);
        }
        public void CreateTest()
        {
            ICommonLogger logger = new ShoutExceptionLogger();
            AmazonS3Settings settings = AmazonS3Settings.FromConfig();
            AmazonFileStorage target = new AmazonFileStorage(logger, settings);
            byte[] fileBytes = File.ReadAllBytes("Content/test2.jpg");
            string pathName = "test.jpg";

            bool result = target.Create(pathName, fileBytes).Result;
            Assert.IsTrue(result);
        }
        private static void RegisterImageParts(IAppBuilder app, ContainerBuilder builder)
        {
            AmazonS3Settings amazonSettings = AmazonS3Settings.FromConfig();
            ICommonLogger logger = new NLogLogger();
            IFileStorage fileStorage = new AmazonFileStorage(logger, amazonSettings);

            var avatarImageSettings = new AvatarImageSettings()
            {
                DefaultImages = new List<string>() {
                    "3ysYtgscfkekTqi5bS6XHw", "5eJ-trR5WUGEQZ49rzj2Kw", "cnGYOdKfX0iUKv1fmkB6KA"
                    , "dC-HU2RSiUSEliqP_5HmwA", "EFgYkW-LTkSAxLvAE3DsvA", "Gi3Xoqq_4k2ZZy-Aa5vsyw"
                    , "HwFfWSqQgUu5FMrrFvGiag", "Kyc0FjFlI0uQ2QyczDGvrg"
                    , "Oh7YIBQofkubrcY7bs8RBw", "OsHpSXSr6EamPZzL0iwx0g", "pfP-ZQinnkOyZHpKzl-wBg"
                    , "qBCQhTdEtECK559zxocntg", "QcvLm8Mdr0uLCVQv752V9g", "R0T754HITEuKho19rdnGXg"
                    , "SiHl9pLsjUGLau9JZxEY_g", "tQ4JINIZAkq4lR2r3EVjhg", "VUqjCVsxAEmz9Yfcv24Q6A"
                    , "vvt1gG9n30WHhiPhF2KttA", "YEVzYN1iZEKgOqi2LUsHCw", "_PIYJMjqLEShFOuWTAaCwA" },
                TempDeleteAge = TimeSpan.FromDays(1),
                SizeLimit = 1124000,
                Targets = new List<ImageTargetParameters>()
                {
                    new ImageTargetParameters()
                    {
                        TargetFormat = ImageFormat.Jpeg,
                        ResizeType = ImageResizeType.FitAndFill,
                        RoundCorners = false,
                        Height = 100,
                        Width = 100,
                        PathCreator = new PathCreator()
                        {
                            UrlBase =  fileStorage.GetBaseUrl(),
                            TempRootFolder = Constants.IMAGE_TEMP_FOLDER_AVATAR,
                            TempFolderFormat = null,
                            TempNameFormat = "{0}{1}.jpeg",
                            StaticRootFolder = Constants.IMAGE_STATIC_FOLDER_AVATAR,
                            StaticFolderFormat = null,
                            StaticNameFormat = "{0}.jpeg"
                        }
                    }
                }
            };

            var previewImageSettings = new ImageSettings()
            {
                Name = Constants.IMAGE_SETTINGS_NAME_PREVIEW,
                TempDeleteAge = TimeSpan.FromDays(1),
                SizeLimit = 5124000,
                Targets = new List<ImageTargetParameters>()
                {
                    new ImageTargetParameters()
                    {
                        TargetFormat = ImageFormat.Jpeg,
                        ResizeType = ImageResizeType.FitAndFill,
                        RoundCorners = false,
                        Width = 750,
                        Height = 420,
                        PathCreator = new PathCreator()
                        {
                            UrlBase = fileStorage.GetBaseUrl(),
                            TempRootFolder = Constants.IMAGE_TEMP_FOLDER_PREVIEW,
                            TempFolderFormat = null,
                            TempNameFormat = "{0}{1}.jpeg",
                            StaticRootFolder = Constants.IMAGE_STATIC_FOLDER_PREVIEW,
                            StaticFolderFormat = null,
                            StaticNameFormat = "{0}.jpeg"
                        }
                    }
                }
            };

            var contentImageSettings = new ImageSettings()
            {
                Name = Constants.IMAGE_SETTINGS_NAME_CONTENT,
                TempDeleteAge = TimeSpan.FromDays(1),
                SizeLimit = 1124000,
                Targets = new List<ImageTargetParameters>()
                {
                    new ImageTargetParameters()
                    {
                        TargetFormat = ImageFormat.Jpeg,
                        ResizeType = ImageResizeType.FitRatio,
                        RoundCorners = false,
                        Width = 600,
                        Height = 600,
                        PathCreator = new PathCreator()
                        {
                            UrlBase = fileStorage.GetBaseUrl(),
                            TempRootFolder = Constants.IMAGE_TEMP_FOLDER_CONTENT,
                            TempFolderFormat = null,
                            TempNameFormat = "{0}{1}.jpeg",
                            StaticRootFolder = Constants.IMAGE_STATIC_FOLDER_CONTENT,
                            StaticFolderFormat = "{0}",
                            StaticNameFormat = "{0}.jpeg"
                        }
                    }
                }
            };

            var commentImageSettings = new ImageSettings()
            {
                Name = Constants.IMAGE_SETTINGS_NAME_COMMENT,
                TempDeleteAge = TimeSpan.FromDays(1),
                SizeLimit = 5124000,
                Targets = new List<ImageTargetParameters>()
                {
                    new ImageTargetParameters()
                    {
                        TargetFormat = ImageFormat.Jpeg,
                        ResizeType = ImageResizeType.FitRatio,
                        Width = 600,
                        Height = 600,
                        RoundCorners = false,
                        PathCreator = new PathCreator()
                        {
                            UrlBase = fileStorage.GetBaseUrl(),
                            TempRootFolder = Constants.IMAGE_TEMP_FOLDER_COMMENT,
                            TempFolderFormat = null,
                            TempNameFormat = "{0}{1}.jpeg",
                            StaticRootFolder = Constants.IMAGE_STATIC_FOLDER_COMMENT,
                            StaticFolderFormat = "{0}",
                            StaticNameFormat = "{0}.jpeg"
                        }
                    }
                }
            };

            builder.RegisterInstance(fileStorage).As<IFileStorage>();
            builder.RegisterType<ImageSettingsFactory>().As<IImageSettingsFactory>();
            builder.RegisterInstance(avatarImageSettings).AsSelf();
            builder.RegisterInstance(previewImageSettings).AsSelf();
            builder.RegisterInstance(contentImageSettings).AsSelf().PreserveExistingDefaults();
            builder.RegisterInstance(commentImageSettings).AsSelf().PreserveExistingDefaults();
            builder.RegisterType<ContentImageQueries>().AsSelf();
            builder.RegisterType<PreviewImageQueries>().AsSelf();
            builder.RegisterType<AvatarImageQueries>().AsSelf();
            builder.RegisterType<CommentImageQueries>().AsSelf();
        }