ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Public Member Functions | Protected Attributes | List of all members
ImageResizer.Plugins.AzureReader.AzureFile Class Reference
Inheritance diagram for ImageResizer.Plugins.AzureReader.AzureFile:
Inheritance graph
[legend]
Collaboration diagram for ImageResizer.Plugins.AzureReader.AzureFile:
Collaboration graph
[legend]

Public Member Functions

 AzureFile (string blobName, AzureVirtualPathProvider parentProvider)
 
override System.IO.Stream Open ()
 Attempts to download the blob into a MemoryStream instance and return it. Throws a FileNotFoundException if the blob doesn't exist. More...
 

Protected Attributes

readonly AzureVirtualPathProvider parent
 

Additional Inherited Members

- Properties inherited from ImageResizer.Plugins.IVirtualFile
string VirtualPath [get]
 The virtual path of the file (relative to the domain, like /app/folder/file.ext) More...
 

Detailed Description

Definition at line 10 of file AzureFile.cs.

Member Function Documentation

override System.IO.Stream ImageResizer.Plugins.AzureReader.AzureFile.Open ( )
inline

Attempts to download the blob into a MemoryStream instance and return it. Throws a FileNotFoundException if the blob doesn't exist.

Returns

Implements ImageResizer.Plugins.IVirtualFile.

Definition at line 21 of file AzureFile.cs.

21  {
22  // Prefix already stripped from virtual path
23 
24  // Get a reference to the blob
25  CloudBlob cloudBlob = parent.CloudBlobClient.GetBlobReference(VirtualPath);
26 
27  MemoryStream ms = new MemoryStream(4096); // 4kb is a good starting point.
28 
29  // Synchronously download
30  try {
31  cloudBlob.DownloadToStream(ms);
32  }
33  catch (StorageClientException e) {
34  if (e.ErrorCode == StorageErrorCode.ResourceNotFound) {
35  throw new FileNotFoundException("Azure blob file not found", e);
36  }
37  else if (e.ErrorCode == StorageErrorCode.ContainerNotFound) {
38  throw new FileNotFoundException("Azure blob container not found", e);
39  }
40  else {
41  throw;
42  }
43  }
44 
45  ms.Seek(0, SeekOrigin.Begin); // Reset to beginning
46  return ms;
47  }
string VirtualPath
The virtual path of the file (relative to the domain, like /app/folder/file.ext)
Definition: IVirtualFile.cs:14

The documentation for this class was generated from the following file: