Table of Contents

Class FileStream

Namespace
Kentico.Xperience.AzureStorage
Assembly
Kentico.Xperience.AzureStorage.dll

Implementation of file stream for Microsoft Azure.

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 Azure blob storage.

public long MaximalPartSize { get; }

Property Value

long

MinimalPartSize

Returns minimal size of the part used in multipart upload process to Azure blob 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, so Azure blob storage can delete uploaded parts.

public void AbortMultiPartUpload(string uploadSessionId)

Parameters

uploadSessionId string

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

Close()

Closes current stream.

public override void Close()

CompleteMultiPartUploadProcess(string, IEnumerable<string>)

Completes multiple part upload process. Sends final request to Azure blob storage to merge all parts already sent.

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>

Identifiers of the parts already sent to Azure blob storage, obtained by calling UploadStreamContentAsMultiPart(string, int)

Returns

string

ETag of the uploaded file.

Dispose(bool)

Releases all unmanaged and optionally managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

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 the stream

protected void InitFileStream()

InitMultiPartUpload()

Inits multipart upload to Azure blob storage.

public string InitMultiPartUpload()

Returns

string

Upload ID, unique identifier for one multipart upload to Azure blob 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 begining of file.

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 data inside a stream in multiple parts to Azure blob storage.

public IEnumerable<string> UploadStreamContentAsMultiPart(string uploadSessionId, int nextPartNumber)

Parameters

uploadSessionId string

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

nextPartNumber int

Number that defines position of the data obtained by the stream in the whole multipart upload process.

Returns

IEnumerable<string>

Unique identifiers of the uploaded parts.

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.