OCISDK/OCISDK/ObjectStorage/ObjectStorageClientAsync.cs
/// <summary>
/// Creates a bucket in the given namespace with a bucket name and optional user-defined metadata. Avoid entering confidential information in bucket names.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Creates a bucket in the given namespace with a bucket name and optional user-defined metadata. Avoid entering confidential information in bucket names.
Creates a bucket in the given namespace with a bucket name and optional user - defined metadata . Avoid entering confidential information in bucket names .
public async Task<CreateBucketResponse> CreateBucket(CreateBucketRequest request)
        {
            var uri = new Uri(GetEndPointNoneVersion(ObjectStorageServices.Bucket(request.NamespaceName), this.Region));
            using (var webResponse = await this.RestClientAsync.Post(uri, request.CreateBucketDetails, new HttpRequestHeaderParam() { OpcClientRequestId = request.OpcClientRequestId }))
            using (var stream = webResponse.GetResponseStream())
            using (var reader = new StreamReader(stream))
            {
                var response = reader.ReadToEnd();
                return new CreateBucketResponse()
                {
                    Bucket = JsonSerializer.Deserialize<Bucket>(response),
                    ETag = webResponse.Headers.Get("ETag"),
                    OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                    OpcClientRequestId = webResponse.Headers.Get("opc-client-request-id"),
                    Location = webResponse.Headers.Get("Location")
                };
            }
        }
public async Task < CreateBucketResponse > CreateBucket ( CreateBucketRequest request ) { var uri = new Uri ( GetEndPointNoneVersion ( ObjectStorageServices . Bucket ( request . NamespaceName ) , this . Region ) ) ; using ( var webResponse = await this . RestClientAsync . Post ( uri , request . CreateBucketDetails , new HttpRequestHeaderParam ( ) { OpcClientRequestId = request . OpcClientRequestId } ) ) using ( var stream = webResponse . GetResponseStream ( ) ) using ( var reader = new StreamReader ( stream ) ) { var response = reader . ReadToEnd ( ) ; return new CreateBucketResponse ( ) { Bucket = JsonSerializer . Deserialize < Bucket > ( response ) , ETag = webResponse . Headers . Get ( " " ) , OpcRequestId = webResponse . Headers . Get ( " " ) , OpcClientRequestId = webResponse . Headers . Get ( " " ) , Location = webResponse . Headers . Get ( " " ) } ; } }
Creates a bucket in the given namespace with a bucket name and optional user-defined metadata.
Creates a bucket in the given namespace with a bucket name and optional user - defined metadata .
None
request
CreateBucketRequest
None