private static void Main(string[] args) { dynamic config = LoadConfiguration("secrets.json"); dynamic aws = config.aws; dynamic DO = config.DO; dynamic azure = config.azure; dynamic gcp = config.gcp; ICredential awsCred = new AWSCredential(aws.id.ToString(), aws.key.ToString(), aws.region.ToString()); ICredential doCred = new DigitalOceanCredential(DO.id.ToString(), DO.key.ToString(), DO.region.ToString()); ICredential azureCred = new AzureCredential(azure.id.ToString(), azure.key.ToString()); ICredential gcpCred = new GCPCredential(gcp.id.ToString(), JsonConvert.SerializeObject(gcp.secret)); Factory fac = new Factory(awsCred, doCred, azureCred, gcpCred); AsyncMain(args, fac).GetAwaiter().GetResult(); }
public static IBucketClient CreateClient(CloudServiceProvider service, ICredential credential) { HttpClient httpClient = new HttpClient(); switch (service) { case CloudServiceProvider.AWS: if (!(credential is AWSCredential)) { throw new ArgumentException("AWS needs AWSCredential!"); } AWSCredential aws = credential as AWSCredential; return(new AWSBucketClient(httpClient, aws.accessKeyID, aws.accessKeySecret, aws.region)); case CloudServiceProvider.Azure: if (!(credential is AzureCredential)) { throw new ArgumentException("Azure needs AzureCredential!"); } AzureCredential azure = credential as AzureCredential; return(new AzureBucketClient(azure.AccountName, azure.Secret)); case CloudServiceProvider.GCP: if (!(credential is GCPCredential)) { throw new ArgumentException("Google Cloud Platform needs GCPCredential!"); } GCPCredential gcp = credential as GCPCredential; return(new GCPBucketClient(gcp.projectID, gcp.secretJSON)); case CloudServiceProvider.DigitalOcean: if (!(credential is DigitalOceanCredential)) { throw new ArgumentException("Digital Ocean needs DigitalOceanCredential!"); } DigitalOceanCredential DO = credential as DigitalOceanCredential; return(new DigitalOceanBucketClient(httpClient, DO.accessKeyID, DO.accessKeySecret, DO.region)); case CloudServiceProvider.AliCloud: throw new NotImplementedException(); } return(null); }
public FileService(IOptions <AWSCredential> aWSCredential, IDataProvider dataProvider) { _dataProvider = dataProvider; _aWSCredential = aWSCredential.Value; }
public FileService(IDataProvider data, IOptions <AWSCredential> awsCredential) { _data = data; _awsCredential = awsCredential.Value; }