Ejemplo n.º 1
0
        private static void ConfigureStorageProvider(IServiceCollection services)
        {
            services.AddTransient <IStorageProvider>(ctx =>
            {
                var azureCfg    = ctx.GetRequiredService <AzureConfiguration>();
                var s3Cfg       = ctx.GetRequiredService <S3Configuration>();
                var physicalCfg = ctx.GetRequiredService <PhysicalConfiguration>();

                if (azureCfg.Enabled)
                {
                    return(new AzureBlobStorageProvider(azureCfg.ConnectionString, azureCfg.ContainerName));
                }
                if (s3Cfg.Enabled)
                {
                    var s3 = new S3StorageProvider(s3Cfg.Endpoint, s3Cfg.BucketName, s3Cfg.AccessKey, s3Cfg.Secret);

                    if (s3Cfg.Minio)
                    {
                        s3.SetForcePathStyle(true);
                        s3.SetS3UsEast1RegionalEndpointValue(Amazon.Runtime.S3UsEast1RegionalEndpointValue.Legacy);
                    }

                    return(s3);
                }
                if (physicalCfg.Enabled)
                {
                    return(new PhysicalStorageProvider());
                }

                throw new Exception($"No storage provider was enabled.");
            });
        }
 public DelayedS3Writer(S3StorageFile file, Stream innerStream, string cannedAcl, S3StorageProvider s3StorageProvider)
 {
     _file            = file;
     _innerStream     = innerStream;
     _storageProvider = s3StorageProvider;
     _cannedAcl       = cannedAcl;
     _buffer          = new MemoryStream();
 }
Ejemplo n.º 3
0
        private static S3StorageProvider GetMockS3Space()
        {
            var space = new S3StorageProvider("http://localhost:9000", "mybucket", "minioadmin", "minioadmin");

            space.SetForcePathStyle(true);
            space.SetS3UsEast1RegionalEndpointValue(Amazon.Runtime.S3UsEast1RegionalEndpointValue.Legacy);

            return(space);
        }
 public S3StorageFile(S3FileInfo s3FileInfo, S3StorageProvider s3StorageProvider)
 {
     _s3FileInfo        = s3FileInfo;
     _s3StorageProvider = s3StorageProvider;
 }