Search Results for

    Show / Hide Table of Contents

    Class NpgsqlLargeObjectStream

    An interface to remotely control the seekable stream for an opened large object on a PostgreSQL server. Note that the OpenRead/OpenReadWrite method as well as all operations performed on this stream must be wrapped inside a database transaction.

    Inheritance
    Object
    MarshalByRefObject
    Stream
    NpgsqlLargeObjectStream
    Implements
    IAsyncDisposable
    IDisposable
    Inherited Members
    Stream.Null
    Stream.BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
    Stream.BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)
    Stream.CopyTo(Stream)
    Stream.CopyTo(Stream, Int32)
    Stream.CopyToAsync(Stream)
    Stream.CopyToAsync(Stream, Int32)
    Stream.CopyToAsync(Stream, Int32, CancellationToken)
    Stream.CopyToAsync(Stream, CancellationToken)
    Stream.CreateWaitHandle()
    Stream.Dispose()
    Stream.DisposeAsync()
    Stream.EndRead(IAsyncResult)
    Stream.EndWrite(IAsyncResult)
    Stream.FlushAsync()
    Stream.FlushAsync(CancellationToken)
    Stream.ObjectInvariant()
    Stream.Read(Span<Byte>)
    Stream.ReadAsync(Byte[], Int32, Int32)
    Stream.ReadAsync(Memory<Byte>, CancellationToken)
    Stream.ReadByte()
    Stream.Synchronized(Stream)
    Stream.Write(ReadOnlySpan<Byte>)
    Stream.WriteAsync(Byte[], Int32, Int32)
    Stream.WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)
    Stream.WriteByte(Byte)
    Stream.ReadTimeout
    Stream.WriteTimeout
    MarshalByRefObject.GetLifetimeService()
    MarshalByRefObject.InitializeLifetimeService()
    MarshalByRefObject.MemberwiseClone(Boolean)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Npgsql
    Assembly: Npgsql.dll
    Syntax
    public sealed class NpgsqlLargeObjectStream : Stream, IAsyncDisposable, IDisposable

    Properties

    CanRead

    CanRead always returns true, unless the stream has been closed.

    Declaration
    public override bool CanRead { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    Stream.CanRead

    CanSeek

    CanSeek always returns true, unless the stream has been closed.

    Declaration
    public override bool CanSeek { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    Stream.CanSeek

    CanTimeout

    CanTimeout always returns false.

    Declaration
    public override bool CanTimeout { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    Stream.CanTimeout

    CanWrite

    CanWrite returns true if the stream was opened with write permissions, and the stream has not been closed.

    Declaration
    public override bool CanWrite { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    Stream.CanWrite

    Has64BitSupport

    Since PostgreSQL 9.3, large objects larger than 2GB can be handled, up to 4TB. This property returns true whether the PostgreSQL version is >= 9.3.

    Declaration
    public bool Has64BitSupport { get; }
    Property Value
    Type Description
    Boolean

    Length

    Gets the length of the large object. This internally seeks to the end of the stream to retrieve the length, and then back again.

    Declaration
    public override long Length { get; }
    Property Value
    Type Description
    Int64
    Overrides
    Stream.Length

    Position

    Returns the current position in the stream. Getting the current position does not need a round-trip to the server, however setting the current position does.

    Declaration
    public override long Position { get; set; }
    Property Value
    Type Description
    Int64
    Overrides
    Stream.Position

    Methods

    Close()

    Releases resources at the backend allocated for this stream.

    Declaration
    public override void Close()
    Overrides
    Stream.Close()

    Dispose(Boolean)

    Releases resources at the backend allocated for this stream, iff disposing is true.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    Boolean disposing

    Whether to release resources allocated at the backend.

    Overrides
    Stream.Dispose(Boolean)

    Flush()

    Does nothing.

    Declaration
    public override void Flush()
    Overrides
    Stream.Flush()

    GetLengthAsync(CancellationToken)

    Gets the length of the large object. This internally seeks to the end of the stream to retrieve the length, and then back again.

    Declaration
    public Task<long> GetLengthAsync(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task<Int64>

    Read(Byte[], Int32, Int32)

    Reads count bytes from the large object. The only case when fewer bytes are read is when end of stream is reached.

    Declaration
    public override int Read(byte[] buffer, int offset, int count)
    Parameters
    Type Name Description
    Byte[] buffer

    The buffer where read data should be stored.

    Int32 offset

    The offset in the buffer where the first byte should be read.

    Int32 count

    The maximum number of bytes that should be read.

    Returns
    Type Description
    Int32

    How many bytes actually read, or 0 if end of file was already reached.

    Overrides
    Stream.Read(Byte[], Int32, Int32)

    ReadAsync(Byte[], Int32, Int32, CancellationToken)

    Reads count bytes from the large object. The only case when fewer bytes are read is when end of stream is reached.

    Declaration
    public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    Byte[] buffer

    The buffer where read data should be stored.

    Int32 offset

    The offset in the buffer where the first byte should be read.

    Int32 count

    The maximum number of bytes that should be read.

    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task<Int32>

    How many bytes actually read, or 0 if end of file was already reached.

    Overrides
    Stream.ReadAsync(Byte[], Int32, Int32, CancellationToken)

    Seek(Int64, SeekOrigin)

    Seeks in the stream to the specified position. This requires a round-trip to the backend.

    Declaration
    public override long Seek(long offset, SeekOrigin origin)
    Parameters
    Type Name Description
    Int64 offset

    A byte offset relative to the origin parameter.

    SeekOrigin origin

    A value of type SeekOrigin indicating the reference point used to obtain the new position.

    Returns
    Type Description
    Int64
    Overrides
    Stream.Seek(Int64, SeekOrigin)

    SeekAsync(Int64, SeekOrigin, CancellationToken)

    Seeks in the stream to the specified position. This requires a round-trip to the backend.

    Declaration
    public Task<long> SeekAsync(long offset, SeekOrigin origin, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    Int64 offset

    A byte offset relative to the origin parameter.

    SeekOrigin origin

    A value of type SeekOrigin indicating the reference point used to obtain the new position.

    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task<Int64>

    SetLength(Int64)

    Truncates or enlarges the large object to the given size. If enlarging, the large object is extended with null bytes. For PostgreSQL versions earlier than 9.3, the value must fit in an Int32.

    Declaration
    public override void SetLength(long value)
    Parameters
    Type Name Description
    Int64 value

    Number of bytes to either truncate or enlarge the large object.

    Overrides
    Stream.SetLength(Int64)

    SetLength(Int64, CancellationToken)

    Truncates or enlarges the large object to the given size. If enlarging, the large object is extended with null bytes. For PostgreSQL versions earlier than 9.3, the value must fit in an Int32.

    Declaration
    public Task SetLength(long value, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    Int64 value

    Number of bytes to either truncate or enlarge the large object.

    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task

    Write(Byte[], Int32, Int32)

    Writes count bytes to the large object.

    Declaration
    public override void Write(byte[] buffer, int offset, int count)
    Parameters
    Type Name Description
    Byte[] buffer

    The buffer to write data from.

    Int32 offset

    The offset in the buffer at which to begin copying bytes.

    Int32 count

    The number of bytes to write.

    Overrides
    Stream.Write(Byte[], Int32, Int32)

    WriteAsync(Byte[], Int32, Int32, CancellationToken)

    Writes count bytes to the large object.

    Declaration
    public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    Byte[] buffer

    The buffer to write data from.

    Int32 offset

    The offset in the buffer at which to begin copying bytes.

    Int32 count

    The number of bytes to write.

    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task
    Overrides
    Stream.WriteAsync(Byte[], Int32, Int32, CancellationToken)

    Implements

    System.IAsyncDisposable
    System.IDisposable
    In This Article
    Back to top © Copyright 2022 The Npgsql Development Team