Class FileStream
- Namespace
- Kentico.Xperience.AzureStorage
- Assembly
- Kentico.Xperience.AzureStorage.dll
Implementation of file stream for Microsoft Azure.
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 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
stringUnique 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
stringUnique 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
intOffset from begining of file.
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 data inside a stream in multiple parts to Azure blob storage.
public IEnumerable<string> UploadStreamContentAsMultiPart(string uploadSessionId, int nextPartNumber)
Parameters
uploadSessionId
stringUnique identifier for one multipart upload. Can be obtained by InitMultiPartUpload() method.
nextPartNumber
intNumber 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
intOffset.
count
intCount.
WriteByte(byte)
Writes byte to the stream.
public override void WriteByte(byte value)
Parameters
value
byteValue to write.