amazon-s3.net-coreibm-cloud-storage

Using AWSSDK.S3 to upload files to IBM COS (S3 compatible) with .net-core


I have some code using AWSSDK.S3 to upload data to S3, no mystery.

Since IBM claims it's Cloud Object Storage to be S3 compatible, it would be possible to use AWSSDK.S3 to upload files to IBM COS by only changing the ServiceURL at appsettings.json?

Does anybody did that before?


Solution

  • I'm not sure about appsettings.json but yes, if you set the ServiceURL to the config used to create a client it should work transparently. Obviously any AWS features that aren't supported by COS wouldn't work, and any COS extensions (like API key auth, or Key Protect, etc) wouldn't be available.

    Something like:

    AmazonS3Config S3Config = new AmazonS3Config {ServiceURL = "https://s3.us.cloud-object-storage.appdomain.cloud"};
    
    string accessKeyId = "<accesskey>";
    string secretAccessKey = "<secretkey>"; 
    
    BasicAWSCredentials credentials = new BasicAWSCredentials(accessKeyId, secretAccessKey); 
    
    AmazonS3Client client = new AmazonS3Client(credentials, S3Config);