ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Public Member Functions | Protected Attributes | Properties | List of all members
ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile Class Reference

Represents a file stored in GridFS and the requested resize settings More...

Inheritance diagram for ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile:
Inheritance graph
[legend]
Collaboration diagram for ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile:
Collaboration graph
[legend]

Public Member Functions

 MongoVirtualFile (MongoReaderPlugin parent, string virtualPath, NameValueCollection query)
 Creates a new MongoVirtualFile More...
 
Stream Open ()
 Locates and opens a GridFS file matching the filename. Using the files id as opposed to its 'friendly' name will improve the response time More...
 
string GetCacheKey (bool includeModifiedDate)
 Returns the virtual folder cache-key More...
 

Protected Attributes

ResizeSettings Query
 Resize settings from the query More...
 
string _virtualPath
 The files virtual path More...
 

Properties

string VirtualPath [get]
 The virtual path to a GridFS file More...
 
- 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

Represents a file stored in GridFS and the requested resize settings

Definition at line 147 of file MongoReaderPlugin.cs.

Constructor & Destructor Documentation

ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile.MongoVirtualFile ( MongoReaderPlugin  parent,
string  virtualPath,
NameValueCollection  query 
)
inline

Creates a new MongoVirtualFile

Parameters
parent
virtualPath
query

Definition at line 168 of file MongoReaderPlugin.cs.

169  {
170  if (!virtualPath.StartsWith(parent.VirtualFilesystemPrefix, StringComparison.OrdinalIgnoreCase))
171  throw new ApplicationException("The specified virtual file must exist within the prefix: " +
172  parent.VirtualFilesystemPrefix);
173  _virtualPath = virtualPath;
174  Query = new ResizeSettings(query);
175  _filename = virtualPath.Substring(parent.VirtualFilesystemPrefix.Length);
176  _parent = parent;
177  }

Member Function Documentation

string ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile.GetCacheKey ( bool  includeModifiedDate)
inline

Returns the virtual folder cache-key

Ignores includeModifiedDate parameter

Parameters
includeModifiedDate
Returns

Implements ImageResizer.Plugins.IVirtualFileSourceCacheKey.

Definition at line 222 of file MongoReaderPlugin.cs.

223  {
224  return VirtualPath;
225  }
Stream ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile.Open ( )
inline

Locates and opens a GridFS file matching the filename. Using the files id as opposed to its 'friendly' name will improve the response time

Returns
A stream containing the requested file

Implements ImageResizer.Plugins.IVirtualFile.

Definition at line 192 of file MongoReaderPlugin.cs.

193  {
194  //First try to get it by id, next by filename
195  if (_filename.StartsWith("id/", StringComparison.OrdinalIgnoreCase))
196  {
197  //Strip the extension and id/ prefix
198  var sid = PathUtils.RemoveFullExtension(_filename.Substring(3));
199 
200  ObjectId id;
201 
202  if (ObjectId.TryParse(sid, out id))
203  {
204  var file = _parent._grid.FindOne(MongoDB.Driver.Builders.Query.EQ("_id", id));
205 
206  if (file == null)
207  throw new FileNotFoundException("Failed to locate blob " + sid + " on GridFS.");
208 
209  return file.OpenRead();
210  }
211  }
212  return _parent._grid.OpenRead(_filename);
213  }

Member Data Documentation

string ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile._virtualPath
protected

The files virtual path

Definition at line 160 of file MongoReaderPlugin.cs.

ResizeSettings ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile.Query
protected

Resize settings from the query

Definition at line 155 of file MongoReaderPlugin.cs.

Property Documentation

string ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile.VirtualPath
get

The virtual path to a GridFS file

Definition at line 183 of file MongoReaderPlugin.cs.


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