aliyun / aliyun-oss-csharp-sdk

Aliyun OSS SDK for C#
MIT License
379 stars 204 forks source link

# Alibaba Cloud OSS SDK for C#

Software License GitHub Version Build Status

README of Chinese

About

Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring massive capacity, security, a low cost, and high reliability.

Version

Run environment

Windows

Install the SDK through GitHub

Install the SDK through DLL reference

Install the SDK through project introduction

Install in Unix/Mac

Install the SDK through NuGet

Install the SDK through GitHub

Install the SDK through DLL reference

MacOS: https://www.microsoft.com/net/download/macos

Linux: https://www.microsoft.com/net/download/linux/build

.Net core runtime 2.0 (or above)

If you just want to run apps of .Net core 2.0, then you need to install the runtime: Windows:https://www.microsoft.com/net/download/windows/run

MacOS: https://www.microsoft.com/net/download/macos/run

Linux: https://www.microsoft.com/net/download/linux/run

Compile OSS SDK with .net core 2.0

To run Samples

Quick use

Get the bucket list (List Bucket)

    OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);    
    var buckets = client.ListBuckets();

    foreach (var bucket in buckets)
    {
        Console.WriteLine(bucket.Name + ", " + bucket.Location + ", " + bucket.Owner);
    }

Create a bucket (Create Bucket)

    OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
    client.CreateBucket(bucketName);

Delete a bucket (Delete Bucket)

    OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret); 
    client.DeleteBucket(bucketName);

Upload a file (Put Object)

    OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret); 
    client.PutObject(bucketName, key, filePathToUpload);

Download an object (Get Object)

    OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret); 
    var object = ossClient.GetObject(bucketName, key);  

Get the object list (List Objects)

    OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
    var listResult = client.ListObjects(bucketName);
    foreach (var summary in listResult.ObjectSummaries)
    {   
        Console.WriteLine(summary.Key);
    }

Delete an object (Delete Object)

    OssClient client = new OssClient(endpoint, accessKeyId, accessKeySecret);
    client.DeleteObject(bucketName, key)

Others

Notes

Contact us