OCISDK/OCISDK/ObjectStorage/ObjectStorageClientAsync.cs
/// <summary>
/// Gets the metadata and body of an object.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Gets the metadata and body of an object.
Gets the metadata and body of an object .
public async Task<GetObjectResponse> GetObject(GetObjectRequest request)
        {
            var uri = new Uri($"{GetEndPointNoneVersion(ObjectStorageServices.Object(request.NamespaceName, request.BucketName), this.Region)}/{request.ObjectName}");
            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                IfMatch = request.IfMatch,
                IfNoneMatch = request.IfNoneMatch,
                OpcClientRequestId = request.OpcClientRequestId,
                Range = request.Range
            };
            using (var webResponse = await this.RestClientAsync.Get(uri, httpRequestHeaderParam))
            using (var stream = webResponse.GetResponseStream())
            using (var reader = new StreamReader(stream))
            {
                var response = reader;
                var contentRange = webResponse.Headers.Get("content-range");
                var opcMeta = webResponse.Headers.Get("opc-meta-*");
                return new GetObjectResponse()
                {
                    FileURL = uri.ToString(),
                    ETag = webResponse.Headers.Get("ETag"),
                    OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                    OpcClientRequestId = webResponse.Headers.Get("opc-client-request-id"),
                    ArchivalState = webResponse.Headers.Get("archival-state"),
                    ContentType = webResponse.Headers.Get("content-type"),
                    ContentLanguage = webResponse.Headers.Get("content-language"),
                    ContentEncoding = webResponse.Headers.Get("content-encoding"),
                    ContentLength = long.Parse(webResponse.Headers.Get("content-length")),
                    ContentMd5 = webResponse.Headers.Get("content-md5"),
                    LastModified = webResponse.Headers.Get("last-modified"),
                    OpcMultipartMd5 = webResponse.Headers.Get("opc-multipart-md5"),
                    TimeOfArchival = webResponse.Headers.Get("time-of-archival")
                };
            }
        }
public async Task < GetObjectResponse > GetObject ( GetObjectRequest request ) { var uri = new Uri ( $" { GetEndPointNoneVersion ( ObjectStorageServices . Object ( request . NamespaceName , request . BucketName ) , this . Region ) } / { request . ObjectName } " ) ; var httpRequestHeaderParam = new HttpRequestHeaderParam ( ) { IfMatch = request . IfMatch , IfNoneMatch = request . IfNoneMatch , OpcClientRequestId = request . OpcClientRequestId , Range = request . Range } ; using ( var webResponse = await this . RestClientAsync . Get ( uri , httpRequestHeaderParam ) ) using ( var stream = webResponse . GetResponseStream ( ) ) using ( var reader = new StreamReader ( stream ) ) { var response = reader ; var contentRange = webResponse . Headers . Get ( " " ) ; var opcMeta = webResponse . Headers . Get ( " " ) ; return new GetObjectResponse ( ) { FileURL = uri . ToString ( ) , ETag = webResponse . Headers . Get ( " " ) , OpcRequestId = webResponse . Headers . Get ( " " ) , OpcClientRequestId = webResponse . Headers . Get ( " " ) , ArchivalState = webResponse . Headers . Get ( " " ) , ContentType = webResponse . Headers . Get ( " " ) , ContentLanguage = webResponse . Headers . Get ( " " ) , ContentEncoding = webResponse . Headers . Get ( " " ) , ContentLength = long . Parse ( webResponse . Headers . Get ( " " ) ) , ContentMd5 = webResponse . Headers . Get ( " " ) , LastModified = webResponse . Headers . Get ( " " ) , OpcMultipartMd5 = webResponse . Headers . Get ( " " ) , TimeOfArchival = webResponse . Headers . Get ( " " ) } ; } }
Gets the metadata and body of an object.
Gets the metadata and body of an object .
None
request
GetObjectRequest
None