public override OssObject Deserialize(ServiceResponse xmlStream) { return(new OssObject(_getObjectRequest.Key) { BucketName = _getObjectRequest.BucketName, Content = xmlStream.Content, Metadata = DeserializerFactory.GetFactory() .CreateGetObjectMetadataResultDeserializer().Deserialize(xmlStream) }); }
public override OssObject Deserialize(ServiceResponse xmlStream) { OssObject ossObject = new OssObject(_getObjectRequest.Key) { BucketName = _getObjectRequest.BucketName, ResponseStream = xmlStream.Content, Metadata = DeserializerFactory.GetFactory() .CreateGetObjectMetadataResultDeserializer().Deserialize(xmlStream) }; DeserializeGeneric(xmlStream, ossObject); var conf = OssUtils.GetClientConfiguration(_serviceClient); var originalStream = ossObject.ResponseStream; var streamLength = ossObject.ContentLength; // setup progress var callback = _getObjectRequest.StreamTransferProgress; if (callback != null) { originalStream = OssUtils.SetupProgressListeners(originalStream, streamLength, conf.ProgressUpdateInterval, _serviceClient, callback); ossObject.ResponseStream = originalStream; } // wrap response stream in MD5Stream if (conf.EnalbeMD5Check) { byte[] expectedHashDigest = null; if (xmlStream.Headers.ContainsKey(HttpHeaders.ContentMd5)) { var md5OfResponse = xmlStream.Headers[HttpHeaders.ContentMd5]; expectedHashDigest = Convert.FromBase64String(md5OfResponse); } var hashStream = new MD5Stream(originalStream, expectedHashDigest, streamLength); ossObject.ResponseStream = hashStream; } else if (conf.EnableCrcCheck && _getObjectRequest.Range == null && string.IsNullOrEmpty(_getObjectRequest.Process)) { byte[] expectedHashDigest = null; if (xmlStream.Headers.ContainsKey(HttpHeaders.HashCrc64Ecma)) { var crcString = xmlStream.Headers[HttpHeaders.HashCrc64Ecma]; ulong crcVal; if (ulong.TryParse(crcString, out crcVal)) { expectedHashDigest = BitConverter.GetBytes(crcVal); var hashStream = new Crc64Stream(originalStream, expectedHashDigest, streamLength); ossObject.ResponseStream = hashStream; } } } return(ossObject); }
public override OssObject Deserialize(ServiceResponse xmlStream) { OssObject ossObject = new OssObject(_request.Key) { BucketName = _request.BucketName, ResponseStream = xmlStream.Content, Metadata = DeserializerFactory.GetFactory() .CreateGetObjectMetadataResultDeserializer().Deserialize(xmlStream) }; DeserializeGeneric(xmlStream, ossObject); if (xmlStream.Headers.ContainsKey("x-oss-select-output-raw") && xmlStream.Headers["x-oss-select-output-raw"].Equals("false")) { var stream = new SelectObjectStream(xmlStream.Content); ossObject.ResponseStream = stream; } return(ossObject); }