### GetObjectMetaAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to GetObjectMetaAsync with a request specifying bucket, key, and version ID. Checks StatusCode and prints the ETag if successful. ```csharp var meta = await client.GetObjectMetaAsync(new() { Bucket = "b", Key = "k", VersionId = "v1" }); if (meta.StatusCode == 200) Console.WriteLine(meta.ETag); ``` -------------------------------- ### ListObjectVersionsAsync method signature and usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Lists object versions and delete markers via HTTP GET /{bucket}?versions&encoding-type=url. The request model includes Delimiter, KeyMarker, VersionIdMarker, MaxKeys, Prefix, EncodingType. The result provides Versions, DeleteMarkers, CommonPrefixes, NextKeyMarker, NextVersionIdMarker, and IsTruncated. The usage example iterates over the returned versions and prints key, version ID, and latest flag. ```csharp public async Task ListObjectVersionsAsync( Models.ListObjectVersionsRequest request, OperationOptions? options = null, CancellationToken cancellationToken = default ) ``` ```csharp var page = await client.ListObjectVersionsAsync(new() { Bucket = "my-bucket" }); foreach (var v in page.Versions ?? []) Console.WriteLine($"{v.Key} {v.VersionId} {v.IsLatest}"); ``` -------------------------------- ### RestoreObjectAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to RestoreObjectAsync with a request specifying bucket, key, and restore parameters (Days=3, Tier=Standard). ```csharp await client.RestoreObjectAsync(new OSS.Models.RestoreObjectRequest { Bucket = "b", Key = "archive.zip", RestoreRequest = new OSS.Models.RestoreRequest { Days = 3, JobParameters = new OSS.Models.JobParameters { Tier = "Standard" } } }); ``` -------------------------------- ### GET /{bucket}/{key}?tagging Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets object tagging. Returns XML Tagging. ```APIDOC ## [GET] /{bucket}/{key}?tagging ### Description Gets object tagging. Returns XML Tagging. ### Method GET ### Endpoint /{bucket}/{key}?tagging ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. ### Response #### Success Response (200) - **Tagging** (XML) - Tagging configuration. ``` -------------------------------- ### IsObjectExistAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to IsObjectExistAsync that prints "object exists" when the object is present. ```csharp if (await client.IsObjectExistAsync("my-bucket", "data/file.txt")) Console.WriteLine("object exists"); ``` -------------------------------- ### GetObjectToFileAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to GetObjectToFileAsync that downloads the object with key "report.pdf" from bucket "b" to /tmp/report.pdf. ```csharp await client.GetObjectToFileAsync( new OSS.Models.GetObjectRequest { Bucket = "b", Key = "report.pdf" }, @"/tmp/report.pdf"); ``` -------------------------------- ### CopyObjectAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to CopyObjectAsync that copies 'original.txt' from 'src-bucket' to 'copy.txt' in 'dest-bucket'. The result contains the copy result metadata. ```csharp var result = await client.CopyObjectAsync(new OSS.Models.CopyObjectRequest { Bucket = "dest-bucket", Key = "copy.txt", SourceBucket = "src-bucket", SourceKey = "original.txt" }); ``` -------------------------------- ### ListBucketsAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to ListBucketsAsync with Prefix and MaxKeys query parameters. Iterates over returned buckets and prints Name, Location, and StorageClass. Uses OSS.Models.ListBucketsRequest. ```csharp var result = await client.ListBucketsAsync(new OSS.Models.ListBucketsRequest { Prefix = "prod-", MaxKeys = 100 }); foreach (var b in result.Buckets ?? []) Console.WriteLine($"{b.Name} {b.Location} {b.StorageClass}"); ``` -------------------------------- ### GET /{bucket}?versioning Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets bucket versioning. Returns XML VersioningConfiguration. ```APIDOC ## [GET] /{bucket}?versioning ### Description Gets bucket versioning. Returns XML VersioningConfiguration. ### Method GET ### Endpoint /{bucket}?versioning ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. ### Response #### Success Response (200) - **VersioningConfiguration** (XML) - Versioning configuration. ``` -------------------------------- ### StaticCredentialsProvider usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Shows how to configure a client with static credentials using the StaticCredentialsProvider. ```csharp cfg.CredentialsProvider = new OSS.Credentials.StaticCredentialsProvider("LTAI...", "secret..."); ``` -------------------------------- ### EnvironmentVariableCredentialsProvider usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Shows how to configure a client with environment variable credentials. Requires OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET to be set; OSS_SESSION_TOKEN is optional. ```csharp // export OSS_ACCESS_KEY_ID=... OSS_ACCESS_KEY_SECRET=... [OSS_SESSION_TOKEN=...] cfg.CredentialsProvider = new OSS.Credentials.EnvironmentVariableCredentialsProvider(); ``` -------------------------------- ### GET /{bucket}?bucketInfo Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets bucket information. Returns XML BucketInfo. ```APIDOC ## [GET] /{bucket}?bucketInfo ### Description Gets bucket information. Returns XML BucketInfo. ### Method GET ### Endpoint /{bucket}?bucketInfo ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. ### Response #### Success Response (200) - **BucketInfo** (XML) - Bucket information. ``` -------------------------------- ### AppendObjectAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Shows how to append lines to an object in a loop, using the previous result's NextAppendPosition as the next Position. ```csharp var pos = 0L; for (int i = 0; i < 3; i++) { var result = await client.AppendObjectAsync(new OSS.Models.AppendObjectRequest { Bucket = "my-bucket", Key = "log.txt", Position = pos, Body = new MemoryStream(Encoding.UTF8.GetBytes($"line {i}\n")) }); pos = result.NextAppendPosition!.Value; } ``` -------------------------------- ### DeleteMultipleObjectsAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to DeleteMultipleObjectsAsync with a request specifying Bucket, Quiet=true, and a list of object keys to delete. ```csharp var result = await client.DeleteMultipleObjectsAsync(new OSS.Models.DeleteMultipleObjectsRequest { Bucket = "b", Quiet = true, Objects = new List { new() { Key = "a.txt" }, new() { Key = "b.txt" } } }); ``` -------------------------------- ### PutObjectFromFileAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to PutObjectFromFileAsync that uploads a local backup.zip file to the "b" bucket with key "backup.zip". ```csharp await client.PutObjectFromFileAsync( new OSS.Models.PutObjectRequest { Bucket = "b", Key = "backup.zip" }, @"/var/data/backup.zip"); ``` -------------------------------- ### GET /{bucket}/{key}?symlink Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets symbolic link information. Response headers include x-oss-symlink-target. ```APIDOC ## [GET] /{bucket}/{key}?symlink ### Description Gets symbolic link information. Response headers include x-oss-symlink-target. ### Method GET ### Endpoint /{bucket}/{key}?symlink ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. ### Response #### Success Response (200) - **Headers** (object) - Symlink metadata. ``` -------------------------------- ### ListObjectsAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example of listing objects with a prefix and delimiter. The page variable holds the result, and the code iterates over Contents to print each object key. ```csharp var page = await client.ListObjectsAsync(new() { Bucket = "my-bucket", Prefix = "docs/", Delimiter = "/" }); foreach (var o in page.Contents ?? []) Console.WriteLine(o.Key); ``` -------------------------------- ### GetObjectAsync usage example with Range Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Downloads a partial object using a Range header. The result exposes HashCrc64 and ContentLength; the body is read via a StreamReader. The task completes when headers arrive, so the body streams. ```csharp using var result = await client.GetObjectAsync(new OSS.Models.GetObjectRequest { Bucket = "my-bucket", Key = "big-file.bin", Range = "bytes=0-1023" // partial download }); Console.WriteLine($"crc={result.HashCrc64} length={result.ContentLength}"); using var reader = new StreamReader(result.Body); Console.WriteLine(await reader.ReadToEndAsync()); ``` -------------------------------- ### PutObjectAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Shows how to upload an object with metadata and progress tracking. The serializer chain adds metadata headers, auto Content-Type (unless disabled or set), CRC64 upload check, and progress reporting. When request.Callback is set, the response body is parsed as JSON callback result. ```csharp var result = await client.PutObjectAsync(new OSS.Models.PutObjectRequest { Bucket = "my-bucket", Key = "dir/hello.txt", Body = new MemoryStream(Encoding.UTF8.GetBytes("hello oss")), Metadata = new Dictionary { ["owner"] = "app" }, ProgressFn = (inc, transferred, total) => Console.WriteLine($"{transferred}/{total}") }); Console.WriteLine(result.ETag); // response ETag Console.WriteLine(result.HashCrc64); // x-oss-hash-crc64ecma ``` -------------------------------- ### Example — option function overriding address style Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Creates a Client with an option function that forces path-style URL construction and query-based signing. Uses StaticCredentialsProvider with hardcoded credentials. ```csharp using OSS = AlibabaCloud.OSS.V2; var cfg = OSS.Configuration.LoadDefault(); cfg.Region = "cn-hangzhou"; cfg.CredentialsProvider = new OSS.Credentials.StaticCredentialsProvider("ak", "sk"); using var client = new OSS.Client(cfg, options => { options.AddressStyle = OSS.AddressStyleType.Path; // force path-style URL construction options.AuthMethod = OSS.AuthMethodType.Query; // sign via query params }); ``` -------------------------------- ### GET /{bucket}/{key}?acl Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets object ACL. Returns XML AccessControlPolicy. ```APIDOC ## [GET] /{bucket}/{key}?acl ### Description Gets object ACL. Returns XML AccessControlPolicy. ### Method GET ### Endpoint /{bucket}/{key}?acl ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. ### Response #### Success Response (200) - **AccessControlPolicy** (XML) - ACL policy. ``` -------------------------------- ### GET /{bucket}?location Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets bucket location. Returns XML LocationConstraint. ```APIDOC ## [GET] /{bucket}?location ### Description Gets bucket location. Returns XML LocationConstraint. ### Method GET ### Endpoint /{bucket}?location ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. ### Response #### Success Response (200) - **LocationConstraint** (XML) - Location constraint. ``` -------------------------------- ### GET /{bucket}?stat Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets bucket statistics. Returns XML BucketStat. ```APIDOC ## [GET] /{bucket}?stat ### Description Gets bucket statistics. Returns XML BucketStat. ### Method GET ### Endpoint /{bucket}?stat ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. ### Response #### Success Response (200) - **BucketStat** (XML) - Bucket statistics. ``` -------------------------------- ### GET /{bucket}?acl Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets bucket ACL. Returns XML AccessControlPolicy. ```APIDOC ## [GET] /{bucket}?acl ### Description Gets bucket ACL. Returns XML AccessControlPolicy. ### Method GET ### Endpoint /{bucket}?acl ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. ### Response #### Success Response (200) - **AccessControlPolicy** (XML) - ACL policy. ``` -------------------------------- ### PutSymlinkAsync method signature and usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Creates a symbolic link via HTTP PUT /{bucket}/{key}?symlink. SymlinkTarget is required via header x-oss-symlink-target; also supports ObjectAcl, StorageClass, ForbidOverwrite. Result exposes VersionId. The usage example creates a symlink from link.txt to real.txt. ```csharp public async Task PutSymlinkAsync( Models.PutSymlinkRequest request, OperationOptions? options = null, CancellationToken cancellationToken = default ) ``` ```csharp await client.PutSymlinkAsync(new OSS.Models.PutSymlinkRequest { Bucket = "b", Key = "link.txt", SymlinkTarget = "real.txt" }); ``` -------------------------------- ### HEAD /{bucket}/{key}?objectMeta Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets object metadata. Query parameter versionId. ```APIDOC ## [HEAD] /{bucket}/{key}?objectMeta ### Description Gets object metadata. Query parameter versionId. ### Method HEAD ### Endpoint /{bucket}/{key}?objectMeta ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. #### Query Parameters - **versionId** (string) - Optional - Version ID. ### Response #### Success Response (200) - **Headers** (object) - Object metadata. ``` -------------------------------- ### PutObjectTaggingAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to PutObjectTaggingAsync that sets a single tag with key 'env' and value 'prod' on object 'k' in bucket 'b'. ```csharp await client.PutObjectTaggingAsync(new OSS.Models.PutObjectTaggingRequest { Bucket = "b", Key = "k", Tagging = new OSS.Models.Tagging { TagSet = new OSS.Models.TagSet { Tags = new List { new() { Key = "env", Value = "prod" } } } } }); ``` -------------------------------- ### GET /{bucket}/{key} Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Downloads an object. Supports Range and If-* headers. Query parameters for response-*, versionId, and x-oss-process. ```APIDOC ## [GET] /{bucket}/{key} ### Description Downloads an object. Supports Range and If-* headers. Query parameters for response-*, versionId, and x-oss-process. ### Method GET ### Endpoint /{bucket}/{key} ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. #### Headers - **Range** (string) - Optional - Byte range. - **If-*** (string) - Optional - Conditional headers. #### Query Parameters - **response-*** (string) - Optional - Response customization. - **versionId** (string) - Optional - Version ID. - **x-oss-process** (string) - Optional - Image processing. ### Response #### Success Response (200) - **Body** (stream) - Object content. ``` -------------------------------- ### ListMultipartUploadsAsync method signature and usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Lists in-progress multipart uploads. Request model supports Delimiter, MaxUploads, KeyMarker, Prefix, UploadIdMarker, EncodingType. Result exposes Uploads (List), IsTruncated, NextKeyMarker, NextUploadIdMarker. The usage example iterates over Uploads and prints Key and UploadId. ```csharp public async Task ListMultipartUploadsAsync( Models.ListMultipartUploadsRequest request, OperationOptions? options = null, CancellationToken cancellationToken = default ) ``` ```csharp var list = await client.ListMultipartUploadsAsync(new() { Bucket = "b", MaxUploads = 100 }); foreach (var u in list.Uploads ?? []) Console.WriteLine($"{u.Key} {u.UploadId}"); ``` -------------------------------- ### GET /?agenticBucket Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Lists all agentic buckets. Supports pagination with continuation tokens and max keys. ```APIDOC ## [GET] /?agenticBucket ### Description Lists all agentic buckets. Supports pagination with continuation tokens and max keys. ### Method GET ### Endpoint `/?agenticBucket` ### Parameters #### Query Parameters - **agenticBucket** - Required - Fixed query parameter - **continuation-token** (string) - Optional - Token for pagination - **max-keys** (integer) - Optional - Maximum number of buckets to return ``` -------------------------------- ### InitiateMultipartUploadAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Shows how to call InitiateMultipartUploadAsync with a request specifying Bucket, Key, and ContentType. The returned UploadId is required for subsequent multipart operations. ```csharp var init = await client.InitiateMultipartUploadAsync(new() { Bucket = "b", Key = "big.bin", ContentType = "application/octet-stream" }); var uploadId = init.UploadId!; ``` -------------------------------- ### GET /{bucket}?uploads Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Lists in-progress multipart uploads in a bucket. Supports filtering by prefix, delimiter, and pagination markers. ```APIDOC ## [GET] /{bucket}?uploads ### Description Lists in-progress multipart uploads in a bucket. Supports filtering by prefix, delimiter, and pagination markers. ### Method GET ### Endpoint `/{bucket}?uploads` ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name #### Query Parameters - **delimiter** (string) - Optional - Delimiter for grouping - **max-uploads** (integer) - Optional - Maximum number of uploads to return - **key-marker** (string) - Optional - Key marker for pagination - **prefix** (string) - Optional - Prefix filter - **upload-id-marker** (string) - Optional - Upload ID marker for pagination - **encoding-type** (string) - Optional - Encoding type ``` -------------------------------- ### Minimal setup with Configuration.LoadDefault Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Loads default configuration, sets region and credentials provider, then optionally customizes endpoint, path style, signature version, retry, timeouts, CRC64 check, and additional headers. Creates an OSS client with the configured settings. ```csharp using OSS = AlibabaCloud.OSS.V2; var cfg = OSS.Configuration.LoadDefault(); cfg.Region = "cn-hangzhou"; cfg.CredentialsProvider = new OSS.Credentials.EnvironmentVariableCredentialsProvider(); // full control example cfg.Endpoint = "oss-cn-hangzhou.aliyuncs.com"; cfg.UsePathStyle = false; cfg.SignatureVersion = "v4"; cfg.RetryMaxAttempts = 5; cfg.ConnectTimeout = TimeSpan.FromSeconds(5); cfg.ReadWriteTimeout = TimeSpan.FromSeconds(30); cfg.DisableUploadCrc64Check = true; // opt out of CRC64 on uploads cfg.AdditionalHeaders = new List { "x-oss-meta-app" }; using var client = new OSS.Client(cfg); ``` -------------------------------- ### GET /{bucket}?agenticBucket&bucketSpace Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Lists bucket spaces within an agentic bucket. Supports prefix filtering and pagination. ```APIDOC ## [GET] /{bucket}?agenticBucket&bucketSpace ### Description Lists bucket spaces within an agentic bucket. Supports prefix filtering and pagination. ### Method GET ### Endpoint `/{bucket}?agenticBucket&bucketSpace` ### Parameters #### Path Parameters - **bucket** (string) - Required - The short bucket name #### Query Parameters - **agenticBucket** - Required - Fixed query parameter - **bucketSpace** - Required - Fixed query parameter - **prefix** (string) - Optional - Prefix filter - **continuation-token** (string) - Optional - Token for pagination - **start-after** (string) - Optional - Start after this key - **max-keys** (integer) - Optional - Maximum number of spaces to return ``` -------------------------------- ### Example — default configuration with environment credentials Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Creates a Client using default configuration loaded from environment, sets the region to cn-hangzhou, and uses EnvironmentVariableCredentialsProvider. The client is disposed via using. ```csharp using OSS = AlibabaCloud.OSS.V2; var cfg = OSS.Configuration.LoadDefault(); cfg.CredentialsProvider = new OSS.Credentials.EnvironmentVariableCredentialsProvider(); cfg.Region = "cn-hangzhou"; using var client = new OSS.Client(cfg); ``` -------------------------------- ### Presign(InitiateMultipartUploadRequest, DateTime?) Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Generates a pre-signed URL for an initiate multipart upload request. The URL can be used to start a multipart upload without additional authentication. ```APIDOC ## [POST] /{bucket}/{key}?uploads ### Description Generates a pre-signed URL for an initiate multipart upload request. The URL can be used to start a multipart upload without additional authentication. ### Method POST ### Endpoint /{bucket}/{key}?uploads ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. #### Query Parameters - **uploads** (string) - Required - Fixed value to indicate multipart upload initiation. #### Request Body - **request** (Models.InitiateMultipartUploadRequest) - Required - The operation to sign. - **expiration** (DateTime?) - Optional - Expiration time. If omitted, defaults to DateTime.UtcNow.AddMinutes(15). ### Response #### Success Response (200) - **Method** (string) - HTTP method of the pre-signed request. - **Url** (string) - The pre-signed URL. - **Expiration** (DateTime) - Expiration time of the URL. - **SignedHeaders** (dictionary) - Headers that must accompany the pre-signed request (content-type, content-md5, x-oss-*, and configured additional headers). Only populated when a non-anonymous credentials provider is present. ``` -------------------------------- ### Client Constructor Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Creates a new Client instance, the primary entry point of the SDK. The constructor accepts a Configuration object and optional option modifier functions that can override resolved values. ```APIDOC ## Client Constructor ### Description Creates a new Client instance, the primary entry point of the SDK. The constructor accepts a Configuration object and optional option modifier functions that can override resolved values. ### Method Constructor ### Signature ```csharp public Client( Configuration config, params Action[] optFns ) ``` ### Parameters - **config** (Configuration) - Required - SDK configuration (region, endpoint, credentials, transport, retry, feature flags). - **optFns** (params Action[]) - Optional - Option modifier functions applied after Configuration is resolved into a ClientOptions; they run in the given order and can override resolved values. ### Example — default configuration with environment credentials ```csharp using OSS = AlibabaCloud.OSS.V2; var cfg = OSS.Configuration.LoadDefault(); cfg.CredentialsProvider = new OSS.Credentials.EnvironmentVariableCredentialsProvider(); cfg.Region = "cn-hangzhou"; using var client = new OSS.Client(cfg); ``` ### Example — option function overriding address style ```csharp using OSS = AlibabaCloud.OSS.V2; var cfg = OSS.Configuration.LoadDefault(); cfg.Region = "cn-hangzhou"; cfg.CredentialsProvider = new OSS.Credentials.StaticCredentialsProvider("ak", "sk"); using var client = new OSS.Client(cfg, options => { options.AddressStyle = OSS.AddressStyleType.Path; // force path-style URL construction options.AuthMethod = OSS.AuthMethodType.Query; // sign via query params }); ``` ``` -------------------------------- ### Publish and run for .NET 9.0 (AOT) Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2/blob/master/test/NuGetVerify/README.md Publishes the project for .NET 9.0 with AOT compilation and runs the resulting executable. Requires vswhere.exe in PATH or a VS Developer Command Prompt. ```bash dotnet publish -c Release --framework net9.0 ``` ```bash bin/Release/net9.0/win-x64/publish/NuGetVerify.exe ``` -------------------------------- ### HeadObjectAsync method signature Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Asynchronously retrieves object metadata via HTTP HEAD /{bucket}/{key}. Requires Bucket and Key in the request. ```csharp public async Task HeadObjectAsync( Models.HeadObjectRequest request, OperationOptions? options = null, CancellationToken cancellationToken = default ) ``` -------------------------------- ### Client constructor signature Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Constructor accepting a Configuration and optional option modifier functions. The optFns run in order after Configuration is resolved into ClientOptions, allowing overrides. ```csharp public Client( Configuration config, params Action[] optFns ) ``` -------------------------------- ### List Buckets with ListBucketsPaginator Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2/blob/master/README.md Lists all buckets in the account using the ListBucketsPaginator. Requires region and environment variables for credentials. Prints bucket name, storage class, and location. ```csharp using OSS = AlibabaCloud.OSS.V2; var region = "cn-hangzhou"; // Using the SDK's default configuration // loading credentials values from the environment variables var cfg = OSS.Configuration.LoadDefault(); cfg.CredentialsProvider = new OSS.Credentials.EnvironmentVariableCredentialsProvider(); cfg.Region = region; using var client = new OSS.Client(cfg); // Create the Paginator for the ListBuckets operation. var paginator = client.ListBucketsPaginator(new OSS.Models.ListBucketsRequest()); // Iterate through the bucket pages Console.WriteLine("Buckets:"); await foreach (var page in paginator.IterPageAsync()) { foreach (var bucket in page.Buckets ?? []) { Console.WriteLine($"Bucket:{bucket.Name}, {bucket.StorageClass}, {bucket.Location}"); } } ``` -------------------------------- ### Run verification for .NET Framework 4.8 (JIT) Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2/blob/master/test/NuGetVerify/README.md Runs the verification project targeting .NET Framework 4.8 using the JIT compiler. ```bash dotnet run --framework net48 ``` -------------------------------- ### Run verification for .NET 8.0 (JIT) Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2/blob/master/test/NuGetVerify/README.md Runs the verification project targeting .NET 8.0 using the JIT compiler. ```bash dotnet run --framework net8.0 ``` -------------------------------- ### CompleteMultipartUploadAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example of calling CompleteMultipartUploadAsync with a list of uploaded parts to complete the multipart upload. ```csharp var done = await client.CompleteMultipartUploadAsync(new OSS.Models.CompleteMultipartUploadRequest { Bucket = "b", Key = "big.bin", UploadId = uploadId, CompleteMultipartUpload = new OSS.Models.CompleteMultipartUpload { Parts = parts } }); ``` -------------------------------- ### Generic call invoking ListObjectsV2 Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Shows a low-level call to ListObjectsV2 using OperationInput. Requires a configured client (cfg). Prints HTTP status and request ID from response headers. ```csharp using OSS = AlibabaCloud.OSS.V2; using var client = new OSS.Client(cfg); var input = new OSS.OperationInput { OperationName = "ListObjectsV2", Method = "GET", Bucket = "my-bucket", Parameters = new Dictionary { { "list-type", "2" } } }; var output = await client.InvokeOperationAsync(input); Console.WriteLine($"HTTP {output.StatusCode}, requestId={output.Headers?["x-oss-request-id"]}"); ``` -------------------------------- ### UploadPartAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example of calling UploadPartAsync to upload a part and adding the returned ETag to a parts list for later completion. ```csharp var part = await client.UploadPartAsync(new OSS.Models.UploadPartRequest { Bucket = "b", Key = "big.bin", PartNumber = 1, UploadId = uploadId, Body = new MemoryStream(bytes) }); parts.Add(new OSS.Models.UploadPart { PartNumber = 1, ETag = part.ETag }); ``` -------------------------------- ### Client class declaration Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Declares the Client as a partial class implementing IDisposable. It is the primary entry point of the SDK, spread over multiple files, with all *Async methods passing through an internal middleware pipeline. ```csharp public partial class Client : IDisposable ``` -------------------------------- ### DescribeRegionsAsync usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example call to DescribeRegionsAsync with a region filter, iterating over the returned RegionInfos to print region IDs and internet endpoints. ```csharp var result = await client.DescribeRegionsAsync(new() { Regions = "cn-hangzhou" }); foreach (var r in result.RegionInfos ?? []) Console.WriteLine($"{r.Region} {r.InternetEndpoint}"); ``` -------------------------------- ### PUT /{bucket}/{key}?tagging Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Sets object tagging. XML body Tagging. ```APIDOC ## [PUT] /{bucket}/{key}?tagging ### Description Sets object tagging. XML body Tagging. ### Method PUT ### Endpoint /{bucket}/{key}?tagging ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. #### Request Body - **Tagging** (XML) - Required - Tagging configuration. ### Response #### Success Response (200) - **Status** (int) - 200 OK ``` -------------------------------- ### List Objects with ListObjectsV2Paginator Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2/blob/master/README.md Lists all objects in a specified bucket using ListObjectsV2Paginator. Requires region, bucket name, and environment credentials. Prints object key, size, and last modified time. ```csharp using OSS = AlibabaCloud.OSS.V2; var region = "cn-hangzhou"; var bucket = "your bucket name"; // Using the SDK's default configuration // loading credentials values from the environment variables var cfg = OSS.Configuration.LoadDefault(); cfg.CredentialsProvider = new OSS.Credentials.EnvironmentVariableCredentialsProvider(); cfg.Region = region; using var client = new OSS.Client(cfg); // Create the Paginator for the ListObjects operation. var paginator = client.ListObjectsV2Paginator(new OSS.Models.ListObjectsV2Request() { Bucket = bucket }); // Lists all objects in a bucket Console.WriteLine("Objects:"); await foreach (var page in paginator.IterPageAsync()) { foreach (var content in page.Contents ?? []) { Console.WriteLine($"Object:{content.Key}, {content.Size}, {content.LastModified}"); } } ``` -------------------------------- ### Configuration.LoadDefault Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Loads the default configuration for the OSS client. This static method returns a Configuration instance with default settings. ```APIDOC ## Configuration.LoadDefault ### Description Loads the default configuration for the OSS client. This static method returns a Configuration instance with default settings. ### Method LoadDefault ### Endpoint Configuration.LoadDefault() ### Parameters None ### Response #### Success Response - **Configuration** (Configuration) - The default configuration instance. ``` -------------------------------- ### PUT /{bucket} Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Creates a bucket. Automatically adds Content-MD5. Supports headers for ACL, resource group, tagging, and agentic bucket. XML body for create bucket configuration. ```APIDOC ## [PUT] /{bucket} ### Description Creates a bucket. Automatically adds Content-MD5. Supports headers for ACL, resource group, tagging, and agentic bucket. XML body for create bucket configuration. ### Method PUT ### Endpoint /{bucket} ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. #### Request Body - **CreateBucketConfiguration** (XML) - Optional - Bucket configuration. ### Response #### Success Response (200) - **Status** (int) - 200 OK ``` -------------------------------- ### GetObjectAclAsync method signature Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Gets object ACL via HTTP GET /{bucket}/{key}?acl. Result exposes AccessControlPolicy and convenience property Acl (the Grant string). ```csharp public async Task GetObjectAclAsync( Models.GetObjectAclRequest request, OperationOptions? options = null, CancellationToken cancellationToken = default ) ``` -------------------------------- ### PutBucketAclAsync method signature and usage example Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Sets the bucket ACL via HTTP PUT /{bucket}?acl with Content-Type: application/xml. The request model PutBucketAclRequest has Bucket and Acl properties; Acl maps to the x-oss-acl header. The example sets the ACL to PublicRead. ```csharp public async Task PutBucketAclAsync( Models.PutBucketAclRequest request, OperationOptions? options = null, CancellationToken cancellationToken = default ) ``` ```csharp await client.PutBucketAclAsync(new() { Bucket = "my-bucket", Acl = OSS.Models.BucketAclType.PublicRead.GetString() }); ``` -------------------------------- ### PUT /{bucket}/{key}?symlink Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Creates a symbolic link. Header x-oss-symlink-target. Supports additional headers for ACL, storage class, and forbid overwrite. ```APIDOC ## [PUT] /{bucket}/{key}?symlink ### Description Creates a symbolic link. Header x-oss-symlink-target. Supports additional headers for ACL, storage class, and forbid overwrite. ### Method PUT ### Endpoint /{bucket}/{key}?symlink ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. #### Headers - **x-oss-symlink-target** (string) - Required - Target object. - **x-oss-object-acl** (string) - Optional - ACL. - **x-oss-storage-class** (string) - Optional - Storage class. - **x-oss-forbid-overwrite** (string) - Optional - Forbid overwrite. ### Response #### Success Response (200) - **Status** (int) - 200 OK ``` -------------------------------- ### ListAgenticBucketsAsync Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Lists all agentic buckets. This operation sends a GET request to the root with the agenticBucket query parameter. ```APIDOC ## [GET] /?agenticBucket ### Description Lists all agentic buckets. ### Method GET ### Endpoint `/?agenticBucket` ### Parameters #### Query Parameters - **ContinuationToken** (string) - Optional - Continuation token for pagination. - **MaxKeys** (integer) - Optional - Maximum number of keys to return. ### Response #### Success Response (200) - **ListAgenticBucketsResult** (object) - List of agentic buckets. ``` -------------------------------- ### ListBucketsPaginator(ListBucketsRequest, PaginatorOptions?) Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Creates a one-shot paginator for listing buckets. Sets request.MaxKeys to options.Limit if provided. ```APIDOC ## ListBucketsPaginator(ListBucketsRequest, PaginatorOptions?) ### Description Creates a one-shot paginator for listing buckets. Sets request.MaxKeys to options.Limit if provided. ### Method Factory method ### Endpoint `client.ListBucketsPaginator(ListBucketsRequest, PaginatorOptions?)` ### Parameters - **request** (ListBucketsRequest) - Required - The request object for listing buckets. - **options** (PaginatorOptions?) - Optional - Paginator options, including Limit. ### Returns `Paginator.IPaginator` ``` -------------------------------- ### EncodingType enum Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Enum for encoding types. Use GetString() to get the wire string value. ```APIDOC ## EncodingType enum ### Description Enum for encoding types. Use GetString() to get the wire string value. ### Values - **Url** - Maps to "url" ### GetString output - `Url` -> `url` ### Example ```csharp var encoding = OSS.Models.EncodingType.Url.GetString(); ``` ``` -------------------------------- ### ListObjectsV2 Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Lists objects in a bucket using the V2 API, supporting continuation tokens and additional options. Returns a list of object summaries and common prefixes. ```APIDOC ## ListObjectsV2 ### Description Lists objects in a bucket using the V2 API, supporting continuation tokens and additional options. Returns a list of object summaries and common prefixes. ### Request - **Bucket** (string) - Required - The bucket name. - **Delimiter** (string) - Optional - A delimiter to group keys. - **MaxKeys** (int) - Optional - The maximum number of keys to return. - **Prefix** (string) - Optional - The prefix filter. - **EncodingType** (string) - Optional - The encoding type for keys. - **FetchOwner** (bool) - Optional - Whether to fetch the owner information. - **StartAfter** (string) - Optional - The start-after key. - **ContinuationToken** (string) - Optional - The continuation token for pagination. ### Response - **Name** (string) - The bucket name. - **MaxKeys** (int) - The maximum number of keys. - **Delimiter** (string) - The delimiter used. - **EncodingType** (string) - The encoding type. - **ContinuationToken** (string) - The continuation token used. - **NextContinuationToken** (string) - The next continuation token. - **Contents** (ObjectSummary[]) - The list of object summaries. - **Prefix** (string) - The prefix used. - **StartAfter** (string) - The start-after key. - **IsTruncated** (bool) - Whether the list is truncated. - **KeyCount** (int) - The number of keys returned. - **CommonPrefixes** (CommonPrefix[]) - The common prefixes. ``` -------------------------------- ### GetObjectTaggingAsync Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Retrieves the tagging of an object. This operation corresponds to the HTTP GET request with the tagging query parameter. ```APIDOC ## GetObjectTaggingAsync ### Description Retrieves the tagging of an object. This operation corresponds to the HTTP GET request with the tagging query parameter. ### Method GET ### Endpoint `/{bucket}/{key}?tagging` ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. ### Response #### Success Response (200) - **Tagging** (object) - The tagging configuration. - **TagSet** (object) - The tag set. - **Tags** (array) - List of tags. ``` -------------------------------- ### POST /{bucket}/{key}?x-oss-async-process Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Asynchronously processes an object. Body x-oss-async-process={Process}. Automatically adds Content-MD5. ```APIDOC ## [POST] /{bucket}/{key}?x-oss-async-process ### Description Asynchronously processes an object. Body x-oss-async-process={Process}. Automatically adds Content-MD5. ### Method POST ### Endpoint /{bucket}/{key}?x-oss-async-process ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. #### Request Body - **x-oss-async-process** (string) - Required - Async process string. ### Response #### Success Response (200) - **Status** (int) - 200 OK ``` -------------------------------- ### GetAgenticBucketAsync Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Retrieves information about an agentic bucket. This operation sends a GET request to the bucket with the agenticBucket query parameter. ```APIDOC ## [GET] /{bucket}?agenticBucket ### Description Retrieves information about an agentic bucket. ### Method GET ### Endpoint `/{bucket}?agenticBucket` ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. ### Response #### Success Response (200) - **GetAgenticBucketResult.AgenticBucketInfo** (object) - Information about the agentic bucket. ``` -------------------------------- ### POST /{bucket}/{key}?x-oss-process Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Processes an object. Body x-oss-process={Process}. Automatically adds Content-MD5. ```APIDOC ## [POST] /{bucket}/{key}?x-oss-process ### Description Processes an object. Body x-oss-process={Process}. Automatically adds Content-MD5. ### Method POST ### Endpoint /{bucket}/{key}?x-oss-process ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. - **key** (string) - Required - The object key. #### Request Body - **x-oss-process** (string) - Required - Process string. ### Response #### Success Response (200) - **Status** (int) - 200 OK ``` -------------------------------- ### ListObjects Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Lists objects in a bucket with optional filtering and pagination. Returns a list of object summaries and common prefixes. ```APIDOC ## ListObjects ### Description Lists objects in a bucket with optional filtering and pagination. Returns a list of object summaries and common prefixes. ### Request - **Bucket** (string) - Required - The bucket name. - **Delimiter** (string) - Optional - A delimiter to group keys. - **Marker** (string) - Optional - The marker for pagination. - **MaxKeys** (int) - Optional - The maximum number of keys to return. - **Prefix** (string) - Optional - The prefix filter. - **EncodingType** (string) - Optional - The encoding type for keys. ### Response - **Name** (string) - The bucket name. - **MaxKeys** (int) - The maximum number of keys. - **Delimiter** (string) - The delimiter used. - **EncodingType** (string) - The encoding type. - **Marker** (string) - The marker used. - **NextMarker** (string) - The next marker for pagination. - **Contents** (ObjectSummary[]) - The list of object summaries. - **Prefix** (string) - The prefix used. - **IsTruncated** (bool) - Whether the list is truncated. - **CommonPrefixes** (CommonPrefix[]) - The common prefixes. ``` -------------------------------- ### CreateAgenticBucketAsync Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Example showing how to create an agentic bucket client and call CreateAgenticBucketAsync. The bucket name is resolved and signed as 'my-agentic-1234567890-cn-hangzhou-ab-apsr'. ```APIDOC ## CreateAgenticBucketAsync ### Description Example showing how to create an agentic bucket client and call CreateAgenticBucketAsync. The bucket name is resolved and signed as `"my-agentic-1234567890-cn-hangzhou-ab-apsr"`. ### Request Example ```csharp using OSS = AlibabaCloud.OSS.V2; var cfg = OSS.Configuration.LoadDefault(); cfg.Region = "cn-hangzhou"; cfg.AccountId = "1234567890"; cfg.CredentialsProvider = new OSS.Credentials.EnvironmentVariableCredentialsProvider(); using var client = new OSS.Agentic.AgenticBucketClient(cfg); await client.CreateAgenticBucketAsync(new OSS.Agentic.Models.CreateAgenticBucketRequest { Bucket = "my-agentic", CreateAgenticBucketConfiguration = new() { StorageClass = "Standard" } }); // resolves & signs for bucket "my-agentic-1234567890-cn-hangzhou-ab-apsr" ``` ``` -------------------------------- ### PUT /{bucket}?versioning Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Sets bucket versioning. XML body VersioningConfiguration. Automatically adds Content-MD5. ```APIDOC ## [PUT] /{bucket}?versioning ### Description Sets bucket versioning. XML body VersioningConfiguration. Automatically adds Content-MD5. ### Method PUT ### Endpoint /{bucket}?versioning ### Parameters #### Path Parameters - **bucket** (string) - Required - The bucket name. #### Request Body - **VersioningConfiguration** (XML) - Required - Versioning configuration. ### Response #### Success Response (200) - **Status** (int) - 200 OK ``` -------------------------------- ### BucketVersioningStatusType enum Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Enum for bucket versioning status. Use GetString() to get the wire string value. ```APIDOC ## BucketVersioningStatusType enum ### Description Enum for bucket versioning status. Use GetString() to get the wire string value. ### Values - **Enabled** - Maps to "Enabled" - **Suspended** - Maps to "Suspended" ### GetString output - `Enabled` -> `Enabled` - `Suspended` -> `Suspended` ### Example ```csharp var status = OSS.Models.BucketVersioningStatusType.Enabled.GetString(); ``` ``` -------------------------------- ### ObjectAclType enum Source: https://github.com/aliyun/alibabacloud-oss-csharp-sdk-v2 Enum for object ACL types. Use GetString() to get the wire string value. ```APIDOC ## ObjectAclType enum ### Description Enum for object ACL types. Use GetString() to get the wire string value. ### Values - **Private** - Maps to "private" - **PublicRead** - Maps to "public-read" - **PublicReadWrite** - Maps to "public-read-write" - **Default** - Maps to "default" ### GetString output - `Private` -> `private` - `PublicRead` -> `public-read` - `PublicReadWrite` -> `public-read-write` - `Default` -> `default` ### Example ```csharp var acl = OSS.Models.ObjectAclType.Private.GetString(); ``` ```