internal bool GetBlobContentsWithoutInitialization(string blobName, Stream outputStream, out BlobProperties properties) { Debug.Assert(outputStream != null); CloudBlobContainer container = GetContainer(); try { var blob = container.GetBlobReference(blobName); blob.DownloadToStream(outputStream); properties = blob.Properties; Log.Write(EventKind.Information, "Getting contents of blob {0}", _client.BaseUri.ToString() + _PathSeparator + _containerName + _PathSeparator + blobName); return true; } catch (InvalidOperationException ex) { if (ex.InnerException is WebException) { var webEx = ex.InnerException as WebException; var resp = webEx.Response as HttpWebResponse; if (resp.StatusCode == HttpStatusCode.NotFound) { properties = null; return false; } else throw; } else throw; } }
/// <summary>Initializes a new instance of the <see cref="BlobProperties"/> class based on an existing instance.</summary> /// <param name="other">The set of properties to clone. </param> public BlobProperties(BlobProperties other) { this.BlobType = other.BlobType; this.ContentEncoding = other.ContentEncoding; this.ContentLanguage = other.ContentLanguage; this.Length = other.Length; this.ContentType = other.ContentType; this.ETag = other.ETag; this.LastModifiedUtc = other.LastModifiedUtc; this.LeaseStatus = other.LeaseStatus; }
internal MemoryStream GetBlobContent(string blobName, out BlobProperties properties) { MemoryStream blobContent = new MemoryStream(); properties = GetBlobContent(blobName, blobContent); blobContent.Seek(0, SeekOrigin.Begin); return blobContent; }
internal bool GetBlobContentsWithoutInitialization(string blobName, Stream outputStream, out BlobProperties properties) { Debug.Assert(outputStream != null, "output strem must not be null"); CloudBlobContainer container = this.GetContainer(); try { var blob = container.GetBlobReference(blobName); blob.DownloadToStream(outputStream); properties = blob.Properties; Log.Write(EventKind.Information, Resource.BlobDownloadMessage, this.blobClient.BaseUri + PathSeparator + this.containerName + PathSeparator + blobName); return true; } catch (InvalidOperationException ex) { if (ex.InnerException is WebException) { var webEx = ex.InnerException as WebException; var resp = webEx.Response as HttpWebResponse; if (resp.StatusCode == HttpStatusCode.NotFound) { properties = null; return false; } else { throw; } } else { throw; } } }