Class S3ObjectInfoProvider
- Namespace
- Kentico.Xperience.AmazonStorage
- Assembly
- Kentico.Xperience.AmazonStorage.dll
Performs operations over the S3 objects.
public class S3ObjectInfoProvider : IS3ObjectInfoProvider
- Inheritance
-
objectS3ObjectInfoProvider
- Implements
- Extension Methods
Fields
ATTRIBUTES
Attributes field name in storage metadata.
public const string ATTRIBUTES = "Attributes"
Field Value
- string
CREATION_TIME
Creation time field name in storage metadata.
public const string CREATION_TIME = "CreationTime"
Field Value
- string
LAST_WRITE_TIME
Last write time field name in storage metadata.
public const string LAST_WRITE_TIME = "LastWriteTime"
Field Value
- string
LOCK
Property name which returns if file is locked for writing.
public const string LOCK = "Lock"
Field Value
- string
MAX_OBJECTS_PER_REQUEST
Indicates maximum number of items processed by one request.
public const int MAX_OBJECTS_PER_REQUEST = 1000
Field Value
- int
Properties
Current
Returns current instance of S3ObjectInfo provider.
public static IS3ObjectInfoProvider Current { get; }
Property Value
Methods
AppendTextToObject(IS3ObjectInfo, string)
Appends text to Amazon S3 storage object.
public void AppendTextToObject(IS3ObjectInfo obj, string content)
Parameters
objIS3ObjectInfoObject info.
contentstringContent to append.
CopyObjects(IS3ObjectInfo, IS3ObjectInfo)
Copies object to another.
public void CopyObjects(IS3ObjectInfo sourceObject, IS3ObjectInfo destObject)
Parameters
sourceObjectIS3ObjectInfoSource object info.
destObjectIS3ObjectInfoDestination object info.
CreateEmptyObject(IS3ObjectInfo)
Creates empty object.
public void CreateEmptyObject(IS3ObjectInfo obj)
Parameters
objIS3ObjectInfoObject info.
DeleteObject(IS3ObjectInfo)
Deletes object from Amazon S3 storage.
public void DeleteObject(IS3ObjectInfo obj)
Parameters
objIS3ObjectInfoObject info.
GetBucketName(string)
Returns bucket name from account info.
public static string GetBucketName(string path)
Parameters
pathstringPath for which is bucket name returned.
Returns
- string
GetDateTimeString(DateTime)
Returns date time as a string type in english culture.
public static string GetDateTimeString(DateTime datetime)
Parameters
datetimeDateTimeDate time.
Returns
- string
GetInfo(string)
Returns new instance of IS3ObjectInfo.
public IS3ObjectInfo GetInfo(string path)
Parameters
pathstringPath with file name.
Returns
GetInfo(string, bool)
Initializes new instance of S3 object info with specified bucket name.
public IS3ObjectInfo GetInfo(string path, bool key)
Parameters
pathstringPath with file name.
keyboolSpecifies that given path is already object key.
Returns
GetObjectContent(IS3ObjectInfo, FileMode, FileAccess, FileShare, int)
Returns object content as a stream.
public Stream GetObjectContent(IS3ObjectInfo obj, FileMode fileMode = FileMode.Open, FileAccess fileAccess = FileAccess.Read, FileShare fileShare = FileShare.Read, int bufferSize = 4096)
Parameters
objIS3ObjectInfoObject info.
fileModeFileModeFile mode.
fileAccessFileAccessFile access.
fileShareFileShareSharing permissions.
bufferSizeintBuffer size.
Returns
- Stream
Remarks
The returned stream operates over a local working copy of the object. When write access is requested, the working copy is always a temporary file separate from the local cache, so the cached content stays consistent with the storage.
GetObjectsList(string, ObjectTypeEnum, bool, bool, bool)
Returns list with objects from given bucket and under given path.
public List<string> GetObjectsList(string path, ObjectTypeEnum type, bool useFlatListing = false, bool lower = true, bool useCache = true)
Parameters
pathstringPath.
typeObjectTypeEnumSpecifies which objects are returned (files, directories, both).
useFlatListingboolWhether flat listing is used (all files from all subdirectories all in the result).
lowerboolSpecifies whether path should be lowered inside method.
useCacheboolIndicates if results should be primary taken from cache to get better performance
Returns
- List<string>
Remarks
In order to allow to distinguish between files and directories, directories are listed with a trailing backslash.
A listing of Directories of any directory other than the root of the storage lists a directory exactly when it exists according to ExistsInS3Storage(string), that is when it is represented by its own object or by any object stored under it. The common prefixes reported by the storage cannot serve the listing, because a common prefix is reported even when every key under it carries a literal relative segment, in which case it represents no directory. A flat listing derives the directories from the listed keys, see Kentico.Xperience.AmazonStorage.S3ObjectInfoProvider.DeriveDirectories(System.Collections.Generic.HashSet{System.String},System.Collections.Generic.HashSet{System.String},System.String,System.String,System.Boolean). A listing of the top directory only confirms each directory by the first valid key stored under it and skips the rest of its keys, see Kentico.Xperience.AmazonStorage.S3ObjectInfoProvider.AddTopDirectoryDirectories(System.Collections.Generic.HashSet{System.String},System.Collections.Generic.HashSet{System.String},Amazon.S3.Model.ListObjectsResponse,Amazon.S3.Model.ListObjectsRequest,System.String,System.Int32@). Unlike a listing of the common prefixes, which costs a request per thousand directories, it costs about a request per large directory, or a request per page of keys of smaller directories, whichever is fewer, on top of the pages of the objects stored directly in the listed directory.
A listing without a path addresses the root of the storage, which spans the whole bucket. It lists the directories by the common prefixes, or by the directory objects when flat, the same way as before, so that a listing of the top directory only never reads every key of the bucket.
Exceptions
- IOException
Thrown when the storage reports a truncated listing which cannot be continued.
GetStringDateTime(string)
Returns date time as a DateTime type converted using english culture.
public static DateTime GetStringDateTime(string datetime)
Parameters
datetimestringString date time.
Returns
- DateTime
ObjectExists(IS3ObjectInfo)
Returns whether object exists.
public bool ObjectExists(IS3ObjectInfo obj)
Parameters
objIS3ObjectInfoObject info.
Returns
- bool
PutDataFromStreamToObject(IS3ObjectInfo, Stream)
Puts data from stream to Amazon S3 storage.
public void PutDataFromStreamToObject(IS3ObjectInfo obj, Stream stream)
Parameters
objIS3ObjectInfoObject info.
streamStreamStream to upload.
PutFileToObject(IS3ObjectInfo, string)
Puts local file to Amazon S3 storage.
public void PutFileToObject(IS3ObjectInfo obj, string pathToSource)
Parameters
objIS3ObjectInfoObject info.
pathToSourcestringPath to local file.
Remarks
For uploading a file from different file system other than local file system to Amazon S3 storage, PutDataFromStreamToObject(IS3ObjectInfo, Stream) method should be used.
PutTextToObject(IS3ObjectInfo, string)
Puts text to Amazon S3 storage object.
public void PutTextToObject(IS3ObjectInfo obj, string content)
Parameters
objIS3ObjectInfoObject info.
contentstringContent to add.