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

An ImageResizer Plugin that retrieves images from a MongoDB/GridFS store More...

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

Classes

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

Public Member Functions

 MongoReaderPlugin (string prefix, MongoDatabase db, MongoGridFSSettings gridSettings)
 Create a MongoReaderPlugin with an existing MongoDatabase and specific settings for GridFS More...
 
 MongoReaderPlugin (NameValueCollection args)
 Create a MongoReaderPlugin from plug-in arguments More...
 
IPlugin Install (Config c)
 Install the MongoReader plugin More...
 
bool Uninstall (Config c)
 Uninstall the MongoReader plugin More...
 
Node RedactFrom (Node resizer)
 Removes connection string attributes for security More...
 
bool FileExists (string virtualPath, NameValueCollection queryString)
 Checks if the virtual path has the same root as our virtual filesystem prefix More...
 
IVirtualFile GetFile (string virtualPath, NameValueCollection queryString)
 Returns a MongoVirtual file matching the path, or null if the path doesn't fall in this virtual root. More...
 

Properties

MongoGridFS GridFS [get]
 A reference to the GridFS instance used to retrieve files. More...
 
string VirtualFilesystemPrefix [get, set]
 Requests starting with this path will be handled by this virtual path provider. Should be in app-relative form: "~/gridfs/". Will be converted to root-relative form upon assigment. Trailing slash required, auto-added. More...
 

Detailed Description

An ImageResizer Plugin that retrieves images from a MongoDB/GridFS store

Definition at line 20 of file MongoReaderPlugin.cs.

Constructor & Destructor Documentation

ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoReaderPlugin ( string  prefix,
MongoDatabase  db,
MongoGridFSSettings  gridSettings 
)
inline

Create a MongoReaderPlugin with an existing MongoDatabase and specific settings for GridFS

Parameters
prefixThe virtual folder representing GridFS assets
dbAn existing MongoDatabase instance
gridSettingsSettings for the GridFS connection

Definition at line 36 of file MongoReaderPlugin.cs.

37  {
38  _db = db;
39  _gridSettings = gridSettings;
40  _grid = _db.GetGridFS(gridSettings);
41  VirtualFilesystemPrefix = prefix;
42  }
string VirtualFilesystemPrefix
Requests starting with this path will be handled by this virtual path provider. Should be in app-rela...
ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoReaderPlugin ( NameValueCollection  args)
inline

Create a MongoReaderPlugin from plug-in arguments

Parameters
args

Definition at line 48 of file MongoReaderPlugin.cs.

49  {
50  VirtualFilesystemPrefix = string.IsNullOrEmpty(args["prefix"]) ? "~/gridfs/" : args["prefix"];
51 
52  var mongoUrl = new MongoUrl(args["connectionString"]);
53 
54  // Using new client, server database initialization. Wordy but recommended.
55  var mongoClient = new MongoClient(mongoUrl);
56  var mongoServer = mongoClient.GetServer();
57  _db = mongoServer.GetDatabase(mongoUrl.DatabaseName);
58  _gridSettings = new MongoGridFSSettings();
59  _grid = _db.GetGridFS(_gridSettings);
60  }
string VirtualFilesystemPrefix
Requests starting with this path will be handled by this virtual path provider. Should be in app-rela...

Member Function Documentation

bool ImageResizer.Plugins.MongoReader.MongoReaderPlugin.FileExists ( string  virtualPath,
NameValueCollection  queryString 
)
inline

Checks if the virtual path has the same root as our virtual filesystem prefix

Parameters
virtualPath
queryString
Returns

Implements ImageResizer.Plugins.IVirtualImageProvider.

Definition at line 125 of file MongoReaderPlugin.cs.

126  {
127  return virtualPath.StartsWith(VirtualFilesystemPrefix, StringComparison.OrdinalIgnoreCase);
128  }
string VirtualFilesystemPrefix
Requests starting with this path will be handled by this virtual path provider. Should be in app-rela...
IVirtualFile ImageResizer.Plugins.MongoReader.MongoReaderPlugin.GetFile ( string  virtualPath,
NameValueCollection  queryString 
)
inline

Returns a MongoVirtual file matching the path, or null if the path doesn't fall in this virtual root.

Parameters
virtualPath
queryString
Returns

Implements ImageResizer.Plugins.IVirtualImageProvider.

Definition at line 137 of file MongoReaderPlugin.cs.

138  {
139  if (!virtualPath.StartsWith(VirtualFilesystemPrefix, StringComparison.OrdinalIgnoreCase)) return null;
140  return new MongoVirtualFile(this, virtualPath, queryString);
141  }
string VirtualFilesystemPrefix
Requests starting with this path will be handled by this virtual path provider. Should be in app-rela...
IPlugin ImageResizer.Plugins.MongoReader.MongoReaderPlugin.Install ( Config  c)
inline

Install the MongoReader plugin

Parameters
c
Returns

Implements ImageResizer.Plugins.IPlugin.

Definition at line 88 of file MongoReaderPlugin.cs.

89  {
90  c.Plugins.add_plugin(this);
91  return this;
92  }
Node ImageResizer.Plugins.MongoReader.MongoReaderPlugin.RedactFrom ( Node  resizer)
inline

Removes connection string attributes for security

Parameters
resizer
Returns

Implements ImageResizer.Plugins.IRedactDiagnostics.

Definition at line 110 of file MongoReaderPlugin.cs.

111  {
112  foreach (var n in resizer.queryUncached("plugins.add"))
113  {
114  if (n.Attrs["connectionString"] != null) n.Attrs.Set("connectionString", "[redacted]");
115  }
116  return resizer;
117  }
bool ImageResizer.Plugins.MongoReader.MongoReaderPlugin.Uninstall ( Config  c)
inline

Uninstall the MongoReader plugin

Parameters
c
Returns

Implements ImageResizer.Plugins.IPlugin.

Definition at line 99 of file MongoReaderPlugin.cs.

100  {
101  c.Plugins.remove_plugin(this);
102  return true;
103  }

Property Documentation

MongoGridFS ImageResizer.Plugins.MongoReader.MongoReaderPlugin.GridFS
get

A reference to the GridFS instance used to retrieve files.

Definition at line 66 of file MongoReaderPlugin.cs.

string ImageResizer.Plugins.MongoReader.MongoReaderPlugin.VirtualFilesystemPrefix
getset

Requests starting with this path will be handled by this virtual path provider. Should be in app-relative form: "~/gridfs/". Will be converted to root-relative form upon assigment. Trailing slash required, auto-added.

Definition at line 74 of file MongoReaderPlugin.cs.

Referenced by ImageResizer.Plugins.MongoReader.MongoReaderPlugin.MongoVirtualFile.MongoVirtualFile().


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