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

Holds settings used to create a SqlReader More...

Public Member Functions

 SqlReaderSettings (System.Collections.Specialized.NameValueCollection args)
 
void FireBeforeAccess (string id)
 Fires the BeforeAccess event More...
 
bool IsStringType (SqlDbType t)
 Returns true if the specified type is a kind of strings More...
 
bool IsIntType (SqlDbType t)
 Returns true if the specified type is a kind of integer More...
 

Properties

bool StripFileExtension [get, set]
 When true, the last file extension segment will be removed from the URL before the SQL Id is parsed. Only relevant when ImageIdType is a string type. Always true for other values. Configured by setting 'extensionPartOfId' to the opposite value. More...
 
bool RegisterAsVirtualPathProvider [get, set]
 (default: true) When true, the SqlReader will be registered as a VirtualPathProvider with ASP.NET, which will make this plugin's virtual files accessible from all code which depends on the VirtualPathProvider system. If trust levels don't allow that, it falls back to IVirtualImageProvider mode, which allows the image resizer to access the files, but not other systems, so you'll need to enable cacheUnmodifiedFiles if you want to access files without resizing them. More...
 
bool RequireImageExtension [get, set]
 (default true) When false, all URLs inside the PathPrefix folder will be assumed to be images, and will be handled by this plugin. You should still use image extensions, otherwise we don't know what content type to send with the response, and browsers will choke. It's also the cleanest way to tell the image resizer what kind of file type you'd like back when you request resizing. This setting is designed to support non-image file serving from the DB. It will also cause conflicts if PathPrefix overlaps with a folder name used for something else. More...
 
bool UntrustedData [get, set]
 (default: false) When true, all requests will be re-encoded before being served to the client. Invalid or malicious images will fail with an error if they cannot be read as images. This should prevent malicious files from being served to the client. More...
 
bool CacheUnmodifiedFiles [get, set]
 (default false). When true, files and unmodified images (i.e, no querystring) will be cached to disk (if they are requested that way) instead of only caching requests for resized images. DiskCache plugin must be installed for this to have any effect. More...
 
bool CheckForModifiedFiles [get, set]
 If true (default), SQL will be consulted on each image view to ensure the cached image is up to date and the original still exists. More...
 
string PathPrefix [get, set]
 Defines a virtual path where database images can be accessed. Defaults to "~/databaseimages/" Ex image URL: localhost/databaseimages/4953.jpg More...
 
string VirtualPathPrefix [get]
 Returns PathPrefix, but with the "~" resolved - I.e, a full virtual path. If the string doesn't start with / or ~, the application path is prepended as if it started with ~/ More...
 
string ConnectionString [get, set]
 The database connection string. Defaults to null. You can specify an existing web.config connection string using the "ConnectionStrings:namedKey" convention. More...
 
bool QueriesAreStoredProcedures [get, set]
 
string ImageBlobQuery [get, set]
 The query that returns the binary image data based on the ID. Defaults to "SELECT Content FROM Images WHERE ImageID=@id" More...
 
string ModifiedDateQuery [get, set]
 The query that returns the modified and created date of the image. Defaults to "Select ModifiedDate, CreatedDate From Images WHERE ImageID=@id". Of all the dates returned by the query, the first non-empty date is used. More...
 
string ImageExistsQuery [get, set]
 The query that returns whether an image exists or not. Defaults to "Select COUNT(ImageID) From Images WHERE ImageID=@id" More...
 
SqlDbType ImageIdType [get, set]
 Specifies the type of ID used for images. Int, string, and GUID types are the only valid values. Throws an ArgumentOutOfRange exception if set to an invalid value. More...
 

Events

AuthorizeEvent BeforeAccess
 Called before accessing any row in the database. The row ID is passed as a string argument. If the current user should not access the row, throw an HttpException(403, "message") More...
 

Detailed Description

Holds settings used to create a SqlReader

Definition at line 16 of file SqlReaderSettings.cs.

Member Function Documentation

void ImageResizer.Plugins.SqlReader.SqlReaderSettings.FireBeforeAccess ( string  id)
inline

Fires the BeforeAccess event

Parameters
id

Definition at line 48 of file SqlReaderSettings.cs.

48  {
49  if (BeforeAccess != null) BeforeAccess(id);
50  }
AuthorizeEvent BeforeAccess
Called before accessing any row in the database. The row ID is passed as a string argument...
bool ImageResizer.Plugins.SqlReader.SqlReaderSettings.IsIntType ( SqlDbType  t)
inline

Returns true if the specified type is a kind of integer

Parameters
t
Returns

Definition at line 199 of file SqlReaderSettings.cs.

199  {
200  return t == System.Data.SqlDbType.Int || t == System.Data.SqlDbType.TinyInt ||
201  t == System.Data.SqlDbType.SmallInt || t == System.Data.SqlDbType.BigInt;
202 
203  }
bool ImageResizer.Plugins.SqlReader.SqlReaderSettings.IsStringType ( SqlDbType  t)
inline

Returns true if the specified type is a kind of strings

Definition at line 189 of file SqlReaderSettings.cs.

189  {
190  return t == System.Data.SqlDbType.VarChar || t == System.Data.SqlDbType.NVarChar ||
191  t == System.Data.SqlDbType.NChar || t == System.Data.SqlDbType.Char;
192 
193  }

Property Documentation

bool ImageResizer.Plugins.SqlReader.SqlReaderSettings.CacheUnmodifiedFiles
getset

(default false). When true, files and unmodified images (i.e, no querystring) will be cached to disk (if they are requested that way) instead of only caching requests for resized images. DiskCache plugin must be installed for this to have any effect.

Definition at line 100 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.Install().

bool ImageResizer.Plugins.SqlReader.SqlReaderSettings.CheckForModifiedFiles
getset

If true (default), SQL will be consulted on each image view to ensure the cached image is up to date and the original still exists.

Definition at line 108 of file SqlReaderSettings.cs.

string ImageResizer.Plugins.SqlReader.SqlReaderSettings.ConnectionString
getset

The database connection string. Defaults to null. You can specify an existing web.config connection string using the "ConnectionStrings:namedKey" convention.

Definition at line 134 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.GetConnectionObj(), and ImageResizer.Plugins.SqlReader.SqlReaderPlugin.GetIssues().

string ImageResizer.Plugins.SqlReader.SqlReaderSettings.ImageBlobQuery
getset

The query that returns the binary image data based on the ID. Defaults to "SELECT Content FROM Images WHERE ImageID=@id"

Definition at line 146 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.GetStream().

string ImageResizer.Plugins.SqlReader.SqlReaderSettings.ImageExistsQuery
getset

The query that returns whether an image exists or not. Defaults to "Select COUNT(ImageID) From Images WHERE ImageID=@id"

Definition at line 166 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.RowExists().

SqlDbType ImageResizer.Plugins.SqlReader.SqlReaderSettings.ImageIdType
getset

Specifies the type of ID used for images. Int, string, and GUID types are the only valid values. Throws an ArgumentOutOfRange exception if set to an invalid value.

Definition at line 176 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.CreateIdParameter(), and ImageResizer.Plugins.SqlReader.SqlReaderPlugin.ParseIdFromVirtualPath().

string ImageResizer.Plugins.SqlReader.SqlReaderSettings.ModifiedDateQuery
getset

The query that returns the modified and created date of the image. Defaults to "Select ModifiedDate, CreatedDate From Images WHERE ImageID=@id". Of all the dates returned by the query, the first non-empty date is used.

Definition at line 157 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.GetCacheDependencyQuery(), and ImageResizer.Plugins.SqlReader.SqlReaderPlugin.GetDateModifiedUtc().

string ImageResizer.Plugins.SqlReader.SqlReaderSettings.PathPrefix
getset

Defines a virtual path where database images can be accessed. Defaults to "~/databaseimages/" Ex image URL: localhost/databaseimages/4953.jpg

Definition at line 116 of file SqlReaderSettings.cs.

bool ImageResizer.Plugins.SqlReader.SqlReaderSettings.RegisterAsVirtualPathProvider
getset

(default: true) When true, the SqlReader will be registered as a VirtualPathProvider with ASP.NET, which will make this plugin's virtual files accessible from all code which depends on the VirtualPathProvider system. If trust levels don't allow that, it falls back to IVirtualImageProvider mode, which allows the image resizer to access the files, but not other systems, so you'll need to enable cacheUnmodifiedFiles if you want to access files without resizing them.

Definition at line 67 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.Install().

bool ImageResizer.Plugins.SqlReader.SqlReaderSettings.RequireImageExtension
getset

(default true) When false, all URLs inside the PathPrefix folder will be assumed to be images, and will be handled by this plugin. You should still use image extensions, otherwise we don't know what content type to send with the response, and browsers will choke. It's also the cleanest way to tell the image resizer what kind of file type you'd like back when you request resizing. This setting is designed to support non-image file serving from the DB. It will also cause conflicts if PathPrefix overlaps with a folder name used for something else.

Definition at line 80 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.Install().

bool ImageResizer.Plugins.SqlReader.SqlReaderSettings.StripFileExtension
getset

When true, the last file extension segment will be removed from the URL before the SQL Id is parsed. Only relevant when ImageIdType is a string type. Always true for other values. Configured by setting 'extensionPartOfId' to the opposite value.

Definition at line 57 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.ParseIdFromVirtualPath().

bool ImageResizer.Plugins.SqlReader.SqlReaderSettings.UntrustedData
getset

(default: false) When true, all requests will be re-encoded before being served to the client. Invalid or malicious images will fail with an error if they cannot be read as images. This should prevent malicious files from being served to the client.

Definition at line 90 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.Install().

string ImageResizer.Plugins.SqlReader.SqlReaderSettings.VirtualPathPrefix
get

Returns PathPrefix, but with the "~" resolved - I.e, a full virtual path. If the string doesn't start with / or ~, the application path is prepended as if it started with ~/

Definition at line 125 of file SqlReaderSettings.cs.

Referenced by ImageResizer.Plugins.SqlReader.SqlReaderPlugin.Install(), and ImageResizer.Plugins.SqlReader.SqlReaderPlugin.ParseIdFromVirtualPath().

Event Documentation

AuthorizeEvent ImageResizer.Plugins.SqlReader.SqlReaderSettings.BeforeAccess

Called before accessing any row in the database. The row ID is passed as a string argument. If the current user should not access the row, throw an HttpException(403, "message")

Definition at line 42 of file SqlReaderSettings.cs.


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