Class FileStream
- Namespace
- Kentico.Xperience.AmazonStorage
- Assembly
- Kentico.Xperience.AmazonStorage.dll
Implementation of FileStream class for Amazon simple storage.
public class FileStream : FileStream, IMultiPartUploadStream
- Inheritance
-
objectMarshalByRefObjectStreamFileStream
- Implements
- Inherited Members
- Extension Methods
Constructors
FileStream(string, FileMode)
Initializes new instance and initializes new system file stream.
public FileStream(string path, FileMode mode)
Parameters
path
stringPath to file.
mode
FileModeFile mode.
FileStream(string, FileMode, FileAccess)
Initializes new instance and initializes new system file stream.
public FileStream(string path, FileMode mode, FileAccess access)
Parameters
path
stringPath to file.
mode
FileModeFile mode.
access
FileAccessFile access.
FileStream(string, FileMode, FileAccess, FileShare)
Initializes new instance and initializes new system file stream.
public FileStream(string path, FileMode mode, FileAccess access, FileShare share)
Parameters
path
stringPath to file.
mode
FileModeFile mode.
access
FileAccessFile access.
share
FileShareSharing permissions.
FileStream(string, FileMode, FileAccess, FileShare, int)
Initializes new instance and initializes new system file stream.
public FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bSize)
Parameters
path
stringPath to file.
mode
FileModeFile mode.
access
FileAccessFile access.
share
FileShareSharing permissions.
bSize
intBuffer size.
Properties
CanRead
Gets a value indicating whether the current stream supports reading.
public override bool CanRead { get; }
Property Value
- bool
CanSeek
Gets a value indicating whether the current stream supports seeking.
public override bool CanSeek { get; }
Property Value
- bool
True if the stream supports seeking, false otherwise.
CanWrite
Gets a value indicating whether the current stream supports writing.
public override bool CanWrite { get; }
Property Value
- bool
Length
Length of stream.
public override long Length { get; }
Property Value
- long
MaximalPartSize
Maximal size of the part used in multipart upload process to Amazon S3 storage.
public long MaximalPartSize { get; }
Property Value
- long
MinimalPartSize
Returns minimal size of the part used in multipart upload process to Amazon S3 storage.
public long MinimalPartSize { get; }
Property Value
- long
Position
Gets or sets position of current stream.
public override long Position { get; set; }
Property Value
- long
Methods
AbortMultiPartUpload(string)
Aborts multipart upload to Amazon S3 storage and removes all resources already uploaded.
public void AbortMultiPartUpload(string uploadSessionId)
Parameters
uploadSessionId
stringUnique identifier for multipart upload process to external storage. Is obtained by InitMultiPartUpload().
Close()
Closes current stream.
public override void Close()
CompleteMultiPartUploadProcess(string, IEnumerable<string>)
Uploads one large file to Amazon S3 storage in smaller parts.
public string CompleteMultiPartUploadProcess(string uploadSessionId, IEnumerable<string> partIdentifiers)
Parameters
uploadSessionId
stringUnique identifier for one multipart upload. Can be obtained by InitMultiPartUpload() method.
partIdentifiers
IEnumerable<string>List of identifiers from Amazon S3 received after uploading each part by UploadStreamContentAsMultiPart(string, int) method.
Returns
- string
ETag of the uploaded file.
Remarks
Stream still needs to be disposed.
Dispose(bool)
Releases all unmanaged and optionally managed resources.
protected override void Dispose(bool disposing)
Parameters
disposing
boolWhen true, managed resources are released.
Flush()
Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
public override void Flush()
InitFileStream()
Initializes file stream object.
protected virtual void InitFileStream()
InitMultiPartUpload()
Inits multipart upload for given path.
public string InitMultiPartUpload()
Returns
- string
Upload ID, unique identifier for one multipart upload to Amazon S3 storage. Returned upload ID is needed for each subsequent multipart upload operation.
Read(byte[], int, int)
Reads data from stream and stores them into array.
public override int Read(byte[] array, int offset, int count)
Parameters
array
byte[]Array where result is stored.
offset
intOffset from file begin.
count
intNumber of characters which are read.
Returns
- int
Seek(long, SeekOrigin)
Sets the position within the current stream to the specified value.
public override long Seek(long offset, SeekOrigin loc)
Parameters
offset
longOffset
loc
SeekOriginLocation
Returns
- long
SetLength(long)
Set length to stream.
public override void SetLength(long value)
Parameters
value
longValue to set.
UploadStreamContentAsMultiPart(string, int)
Uploads stream's content to Amazon S3 storage as one part of the file in multipart upload process
identified by uploadSessionId
.
public IEnumerable<string> UploadStreamContentAsMultiPart(string uploadSessionId, int nextPartNumber)
Parameters
uploadSessionId
stringUnique identifier for one multipart upload. Can be obtained by InitMultiPartUpload().
nextPartNumber
intNumber that defines position of the data obtained by the stream in the whole multipart upload process.
Returns
- IEnumerable<string>
One unique identifier of the uploaded part in collection.
Remarks
Always returns one ETag in collection. If stream's length is more than 5GB then exception is thrown.
Write(byte[], int, int)
Writes sequence of bytes to stream.
public override void Write(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]Buffer.
offset
intOffset.
count
intCount.
WriteByte(byte)
Writes byte to the stream.
public override void WriteByte(byte value)
Parameters
value
byteValue to write.