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

Allows clients to request objects located on another amazon S3 server through this server. Allows URL rewriting. More...

Inheritance diagram for ImageResizer.Plugins.S3Reader.S3VirtualPathProvider:
Inheritance graph
[legend]
Collaboration diagram for ImageResizer.Plugins.S3Reader.S3VirtualPathProvider:
Collaboration graph
[legend]

Public Member Functions

delegate void RewriteBucketAndKeyPath (S3VirtualPathProvider sender, S3PathEventArgs e)
 
string FilterPath (string path)
 Execites the PreS3RequestFilter event and returns the result. More...
 
 S3VirtualPathProvider (AmazonS3Client s3client, String virtualFilesystemPrefix, TimeSpan absoluteMetadataExpiration, TimeSpan slidingMetadataExpiration, RewriteBucketAndKeyPath bucketFilterCallback, Boolean fastMode)
 Create and configure a virtual path provider. More...
 
 S3VirtualPathProvider (RewriteBucketAndKeyPath bucketFilterCallback, Boolean fastMode)
 Default settings: CommunicationProtocol=HTTP, VirtualFileSystemPrefix = "~/s3", SlidingExpiration = 1h, AbsoluteExpiration = maxvalue No bucket filtering is performed, so any amazon-hosted bucket can be accessed through this provider unless you add a bucket filter. More...
 
bool IsPathVirtual (string virtualPath)
 Determines whether a specified virtual path is within the virtual file system. More...
 
override bool FileExists (string virtualPath)
 
override VirtualFile GetFile (string virtualPath)
 
override CacheDependency GetCacheDependency (string virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
 
bool FileExists (string virtualPath, System.Collections.Specialized.NameValueCollection queryString)
 
IVirtualFile GetFile (string virtualPath, System.Collections.Specialized.NameValueCollection queryString)
 
- Public Member Functions inherited from ImageResizer.Plugins.IVirtualImageProvider
bool FileExists (string virtualPath, NameValueCollection queryString)
 Returns true if the specified file exists. More...
 
IVirtualFile GetFile (string virtualPath, NameValueCollection queryString)
 Returns a virtual file instance for the specified path and querystring. More...
 

Protected Member Functions

override void Initialize ()
 

Properties

string VirtualFilesystemPrefix [get, set]
 Requests starting with this path will be handled by this virtual path provider. Should be in app-relative form: "~/s3/". Will be converted to root-relative form upon assigment. Trailing slash required, auto-added. More...
 
TimeSpan MetadataAbsoluteExpiration [get, set]
 Existence and modified date metadata about files is cached for, at longest, this amount of time after it is first stored. More...
 
TimeSpan MetadataSlidingExpiration [get, set]
 Existence and modified date metadata about files is cached for this long after it is last accessed. More...
 
AmazonS3Client S3Client [get, set]
 Gets and sets the AmazonS3Client object that specifies connection details such as authentication, encryption, etc. More...
 
bool FastMode [get, set]
 If true, existence of bucket and key is assumed as long as prefix is present. Defaults to true. Also, no modified date information is provided, so the cache never gets updated. Requires 1 request instead of 2 to download the image. More...
 

Events

RewriteBucketAndKeyPath PreS3RequestFilter
 Important! You should handle this event and throw an exception if a bucket that you do not own is requested. Otherwise other people's buckets could be accessed using your server. More...
 

Detailed Description

Allows clients to request objects located on another amazon S3 server through this server. Allows URL rewriting.

Definition at line 18 of file S3VirtualPathProvider.cs.

Constructor & Destructor Documentation

ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.S3VirtualPathProvider ( AmazonS3Client  s3client,
String  virtualFilesystemPrefix,
TimeSpan  absoluteMetadataExpiration,
TimeSpan  slidingMetadataExpiration,
RewriteBucketAndKeyPath  bucketFilterCallback,
Boolean  fastMode 
)
inline

Create and configure a virtual path provider.

Parameters
s3clientProvide the authentication and ecryption settings. For public buckets, no settings are required. Use AmazonS3Config.CommunicationProtocol=HTTP for best performance.
virtualFilesystemPrefixThe virtual folder to allow client access of s3 from.
absoluteMetadataExpiration
slidingMetadataExpiration
bucketFilterCallbackYou should validate that the requested bucket is your own. If you only want one bucket, just prefix your bucket to the path.
fastModeIf true, existence of bucket and key is assumed as long as prefix is present. Also, no modified date information is provided to the image resizer, so the cache never gets updated. Requires 1 request instead of 2 to download the image.

Definition at line 109 of file S3VirtualPathProvider.cs.

110  : base()
111  {
112  this.s3Client = s3client;
113  this.VirtualFilesystemPrefix = virtualFilesystemPrefix;
114  this.MetadataAbsoluteExpiration = absoluteMetadataExpiration;
115  this.MetadataSlidingExpiration = slidingMetadataExpiration;
116  this.PreS3RequestFilter += bucketFilterCallback;
117  this.FastMode = fastMode;
118  }
ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.S3VirtualPathProvider ( RewriteBucketAndKeyPath  bucketFilterCallback,
Boolean  fastMode 
)
inline

Default settings: CommunicationProtocol=HTTP, VirtualFileSystemPrefix = "~/s3", SlidingExpiration = 1h, AbsoluteExpiration = maxvalue No bucket filtering is performed, so any amazon-hosted bucket can be accessed through this provider unless you add a bucket filter.

Parameters
bucketFilterCallbackYou should validate that the requested bucket is your own. If you only want one bucket, just prefix your bucket to the path.
fastModeIf true, existence of bucket and key is assumed as long as prefix is present. Also, no modified date information is provided to the image resizer, so the cache never gets updated. Requires 1 request instead of 2 to download the image.

Definition at line 126 of file S3VirtualPathProvider.cs.

127  : base()
128  {
129  this.s3Client = new AmazonS3Client(null,new AmazonS3Config() { UseSecureStringForAwsSecretKey = false, CommunicationProtocol = Amazon.S3.Model.Protocol.HTTP });
130  this.PreS3RequestFilter += bucketFilterCallback;
131  this.FastMode = fastMode;
132  }

Member Function Documentation

string ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.FilterPath ( string  path)
inline

Execites the PreS3RequestFilter event and returns the result.

Parameters
path
Returns

Definition at line 33 of file S3VirtualPathProvider.cs.

34  {
35  S3PathEventArgs e = new S3PathEventArgs(path);
36  if (PreS3RequestFilter != null) PreS3RequestFilter(this,e);
37  return e.Path;
38  }
RewriteBucketAndKeyPath PreS3RequestFilter
Important! You should handle this event and throw an exception if a bucket that you do not own is req...
bool ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.IsPathVirtual ( string  virtualPath)
inline

Determines whether a specified virtual path is within the virtual file system.

Parameters
virtualPathAn absolute virtual path.
Returns
true if the virtual path is within the virtual file sytem; otherwise, false.

Definition at line 148 of file S3VirtualPathProvider.cs.

149  {
150  return virtualPath.StartsWith(VirtualFilesystemPrefix, StringComparison.OrdinalIgnoreCase);
151  }
string VirtualFilesystemPrefix
Requests starting with this path will be handled by this virtual path provider. Should be in app-rela...

Property Documentation

bool ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.FastMode
getset

If true, existence of bucket and key is assumed as long as prefix is present. Defaults to true. Also, no modified date information is provided, so the cache never gets updated. Requires 1 request instead of 2 to download the image.

Definition at line 99 of file S3VirtualPathProvider.cs.

TimeSpan ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.MetadataAbsoluteExpiration
getset

Existence and modified date metadata about files is cached for, at longest, this amount of time after it is first stored.

Definition at line 54 of file S3VirtualPathProvider.cs.

TimeSpan ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.MetadataSlidingExpiration
getset

Existence and modified date metadata about files is cached for this long after it is last accessed.

Definition at line 70 of file S3VirtualPathProvider.cs.

AmazonS3Client ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.S3Client
getset

Gets and sets the AmazonS3Client object that specifies connection details such as authentication, encryption, etc.

Definition at line 89 of file S3VirtualPathProvider.cs.

string ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.VirtualFilesystemPrefix
getset

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

Definition at line 45 of file S3VirtualPathProvider.cs.

Event Documentation

RewriteBucketAndKeyPath ImageResizer.Plugins.S3Reader.S3VirtualPathProvider.PreS3RequestFilter

Important! You should handle this event and throw an exception if a bucket that you do not own is requested. Otherwise other people's buckets could be accessed using your server.

Definition at line 26 of file S3VirtualPathProvider.cs.


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