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.S3Reader.S3PathEventArgs Class Reference

Class to allow modifying the bucket and key request path More...

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

Public Member Functions

 S3PathEventArgs (string path)
 Create a new instance of S3PathEventArgs for modifying the bucket and key of incoming requests More...
 
void AssertBucketMatches (params string[] buckets)
 Stops the request if it doesn't match one of the allowed buckets. Amazon S3 is case-sensitive. Thus, comparisons are case sensitive as well. To minimize headache, a different exception is thrown when only case differs. More...
 
void ThrowException ()
 Throws an HTTP 403 Not Authorized exception. Call this if an invalid bucket request comes through. More...
 
void ThrowInvalidCaseException ()
 Like ThrowException, but hints that the bucket casing is wrong. More...
 
void PrefixBucket (String bucket)
 Prefixes the specified bucket to the requested path. More...
 

Protected Attributes

string _path
 

Properties

string Path [get, set]
 Path contains the bucket and key in the form "bucket/key". Where key may contain additional forward slashes. More...
 
string Bucket [get]
 Parses the bucket from Path More...
 
string Key [get]
 Parses the key from Path More...
 

Detailed Description

Class to allow modifying the bucket and key request path

Definition at line 14 of file S3PathEventArgs.cs.

Constructor & Destructor Documentation

ImageResizer.Plugins.S3Reader.S3PathEventArgs.S3PathEventArgs ( string  path)
inline

Create a new instance of S3PathEventArgs for modifying the bucket and key of incoming requests

Parameters
path

Definition at line 20 of file S3PathEventArgs.cs.

20  {
21  _path = path;
22  }

Member Function Documentation

void ImageResizer.Plugins.S3Reader.S3PathEventArgs.AssertBucketMatches ( params string[]  buckets)
inline

Stops the request if it doesn't match one of the allowed buckets. Amazon S3 is case-sensitive. Thus, comparisons are case sensitive as well. To minimize headache, a different exception is thrown when only case differs.

Parameters
buckets

Definition at line 36 of file S3PathEventArgs.cs.

36  {
37  bool found = false;
38  string b = Bucket;
39  //Look for exact match
40  foreach (string s in buckets) if (s.Equals(b,StringComparison.InvariantCulture)) { found = true; break; }
41  //If no exact matches, but a case-insensitive match exists, tell the user
42  if (!found) foreach (string s in buckets) if (s.Equals(b, StringComparison.InvariantCultureIgnoreCase)) { ThrowInvalidCaseException(); }
43  //Throw exception if needed
44  if (!found) ThrowException();
45  }
void ThrowInvalidCaseException()
Like ThrowException, but hints that the bucket casing is wrong.
string Bucket
Parses the bucket from Path
void ThrowException()
Throws an HTTP 403 Not Authorized exception. Call this if an invalid bucket request comes through...
void ImageResizer.Plugins.S3Reader.S3PathEventArgs.PrefixBucket ( String  bucket)
inline

Prefixes the specified bucket to the requested path.

Parameters
bucket

Definition at line 65 of file S3PathEventArgs.cs.

65  {
66  bucket = bucket.Trim('\\', '/');
67  Path = bucket + "/" + Path.TrimStart('/');
68  }
string Path
Path contains the bucket and key in the form "bucket/key". Where key may contain additional forward s...
void ImageResizer.Plugins.S3Reader.S3PathEventArgs.ThrowException ( )
inline

Throws an HTTP 403 Not Authorized exception. Call this if an invalid bucket request comes through.

Definition at line 50 of file S3PathEventArgs.cs.

50  {
51  throw new ImageProcessingException(403, "You have not permitted access to this amazon S3 bucket.");
52  }
void ImageResizer.Plugins.S3Reader.S3PathEventArgs.ThrowInvalidCaseException ( )
inline

Like ThrowException, but hints that the bucket casing is wrong.

Definition at line 57 of file S3PathEventArgs.cs.

57  {
58  throw new FileNotFoundException("Amazon S3 is case sensitive. Check your requested bucket name to verify correct casing.");
59  }

Property Documentation

string ImageResizer.Plugins.S3Reader.S3PathEventArgs.Bucket
get

Parses the bucket from Path

Returns

Definition at line 73 of file S3PathEventArgs.cs.

string ImageResizer.Plugins.S3Reader.S3PathEventArgs.Key
get

Parses the key from Path

Returns

Definition at line 88 of file S3PathEventArgs.cs.

string ImageResizer.Plugins.S3Reader.S3PathEventArgs.Path
getset

Path contains the bucket and key in the form "bucket/key". Where key may contain additional forward slashes.

Definition at line 27 of file S3PathEventArgs.cs.


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