OCISDK/OCISDK/ObjectStorage/ObjectStorageClientAsync.cs
/// <summary>
/// Creates a new object or overwrites an existing object with the same name. The maximum object size allowed by PutObject is 50 GiB.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Creates a new object or overwrites an existing object with the same name. The maximum object size allowed by PutObject is 50 GiB.
Creates a new object or overwrites an existing object with the same name . The maximum object size allowed by PutObject is 50 GiB .
public async Task<PutObjectResponse> PutObject(PutObjectRequest request)
        {
            var uri = new Uri($"{GetEndPointNoneVersion(ObjectStorageServices.Object(request.NamespaceName, request.BucketName), this.Region)}/{request.ObjectName}");
            HttpRequestHeaderParam HttpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                IfMatch = request.IfMatch,
                IfNoneMatch = request.IfNoneMatch,
                Expect = request.Expect,
                ContentLength = request.ContentLength,
                ContentMD5 = request.ContentMD5,
                OpcClientRequestId = request.OpcClientRequestId,
                ContentType = request.ContentType,
                ContentLanguage = request.ContentLanguage,
                ContentEncoding = request.ContentEncoding,
                ContentDisposition = request.ContentDisposition,
                CacheControl = request.CacheControl,
                OpcMeta = request.OpcMeta
            };
            using (var webResponse = await this.RestClientAsync.Put(uri, request.UploadPartBody, HttpRequestHeaderParam))
            using (var stream = webResponse.GetResponseStream())
            using (var reader = new StreamReader(stream))
            {
                var response = reader.ReadToEnd();
                return new PutObjectResponse()
                {
                    ETag = webResponse.Headers.Get("ETag"),
                    OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                    OpcClientRequestId = webResponse.Headers.Get("opc-client-request-id"),
                    OpcContentMd5 = webResponse.Headers.Get("opc-content-md5"),
                    LastModified = webResponse.Headers.Get("last-modified")
                };
            }
        }
public async Task < PutObjectResponse > PutObject ( PutObjectRequest request ) { var uri = new Uri ( $" { GetEndPointNoneVersion ( ObjectStorageServices . Object ( request . NamespaceName , request . BucketName ) , this . Region ) } / { request . ObjectName } " ) ; HttpRequestHeaderParam HttpRequestHeaderParam = new HttpRequestHeaderParam ( ) { IfMatch = request . IfMatch , IfNoneMatch = request . IfNoneMatch , Expect = request . Expect , ContentLength = request . ContentLength , ContentMD5 = request . ContentMD5 , OpcClientRequestId = request . OpcClientRequestId , ContentType = request . ContentType , ContentLanguage = request . ContentLanguage , ContentEncoding = request . ContentEncoding , ContentDisposition = request . ContentDisposition , CacheControl = request . CacheControl , OpcMeta = request . OpcMeta } ; using ( var webResponse = await this . RestClientAsync . Put ( uri , request . UploadPartBody , HttpRequestHeaderParam ) ) using ( var stream = webResponse . GetResponseStream ( ) ) using ( var reader = new StreamReader ( stream ) ) { var response = reader . ReadToEnd ( ) ; return new PutObjectResponse ( ) { ETag = webResponse . Headers . Get ( " " ) , OpcRequestId = webResponse . Headers . Get ( " " ) , OpcClientRequestId = webResponse . Headers . Get ( " " ) , OpcContentMd5 = webResponse . Headers . Get ( " " ) , LastModified = webResponse . Headers . Get ( " " ) } ; } }
Creates a new object or overwrites an existing object with the same name.
Creates a new object or overwrites an existing object with the same name .
None
request
PutObjectRequest
None