Table of Contents

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
object
MarshalByRefObject
Stream
FileStream
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 string

Path to file.

mode FileMode

File mode.

FileStream(string, FileMode, FileAccess)

Initializes new instance and initializes new system file stream.

public FileStream(string path, FileMode mode, FileAccess access)

Parameters

path string

Path to file.

mode FileMode

File mode.

access FileAccess

File 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 string

Path to file.

mode FileMode

File mode.

access FileAccess

File access.

share FileShare

Sharing 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 string

Path to file.

mode FileMode

File mode.

access FileAccess

File access.

share FileShare

Sharing permissions.

bSize int

Buffer 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 string

Unique 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 string

Unique 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 bool

When 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 int

Offset from file begin.

count int

Number 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 long

Offset

loc SeekOrigin

Location

Returns

long

SetLength(long)

Set length to stream.

public override void SetLength(long value)

Parameters

value long

Value 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 string

Unique identifier for one multipart upload. Can be obtained by InitMultiPartUpload().

nextPartNumber int

Number 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 int

Offset.

count int

Count.

WriteByte(byte)

Writes byte to the stream.

public override void WriteByte(byte value)

Parameters

value byte

Value to write.