Search Results for

    Show / Hide Table of Contents

    Class NpgsqlLargeObjectManager

    Large object manager. This class can be used to store very large files in a PostgreSQL database.

    Inheritance
    object
    NpgsqlLargeObjectManager
    Namespace: Npgsql
    Assembly: Npgsql.dll
    Syntax
    public class NpgsqlLargeObjectManager

    Constructors

    | Improve this Doc View Source

    NpgsqlLargeObjectManager(NpgsqlConnection)

    Creates an NpgsqlLargeObjectManager for this connection. The connection must be opened to perform remote operations.

    Declaration
    public NpgsqlLargeObjectManager(NpgsqlConnection connection)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    Properties

    | Improve this Doc View Source

    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
    bool
    | Improve this Doc View Source

    MaxTransferBlockSize

    The largest chunk size (in bytes) read and write operations will read/write each roundtrip to the network. Default 4 MB.

    Declaration
    public int MaxTransferBlockSize { get; set; }
    Property Value
    Type Description
    int

    Methods

    | Improve this Doc View Source

    Create(uint)

    Create an empty large object in the database. If an oid is specified but is already in use, an PostgresException will be thrown.

    Declaration
    public uint Create(uint preferredOid = null)
    Parameters
    Type Name Description
    uint preferredOid

    A preferred oid, or specify 0 if one should be automatically assigned

    Returns
    Type Description
    uint

    The oid for the large object created

    Exceptions
    Type Condition
    PostgresException

    If an oid is already in use

    | Improve this Doc View Source

    CreateAsync(uint, CancellationToken)

    Create an empty large object in the database. If an oid is specified but is already in use, an PostgresException will be thrown.

    Declaration
    public Task<uint> CreateAsync(uint preferredOid, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    uint preferredOid

    A preferred oid, or specify 0 if one should be automatically assigned

    CancellationToken cancellationToken

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

    Returns
    Type Description
    Task<><uint>

    The oid for the large object created

    Exceptions
    Type Condition
    PostgresException

    If an oid is already in use

    | Improve this Doc View Source

    ExportRemote(uint, string)

    Exports a large object stored in the database to a file on the backend. This requires superuser permissions.

    Declaration
    public void ExportRemote(uint oid, string path)
    Parameters
    Type Name Description
    uint oid

    Oid of the object to export

    string path

    Path to write the file on the backend

    | Improve this Doc View Source

    ExportRemoteAsync(uint, string, CancellationToken)

    Exports a large object stored in the database to a file on the backend. This requires superuser permissions.

    Declaration
    public Task ExportRemoteAsync(uint oid, string path, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    uint oid

    Oid of the object to export

    string path

    Path to write the file on the backend

    CancellationToken cancellationToken

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

    Returns
    Type Description
    Task
    | Improve this Doc View Source

    ImportRemote(string, uint)

    Imports a large object to be stored as a large object in the database from a file stored on the backend. This requires superuser permissions.

    Declaration
    public void ImportRemote(string path, uint oid = null)
    Parameters
    Type Name Description
    string path

    Path to read the file on the backend

    uint oid

    A preferred oid, or specify 0 if one should be automatically assigned

    | Improve this Doc View Source

    ImportRemoteAsync(string, uint, CancellationToken)

    Imports a large object to be stored as a large object in the database from a file stored on the backend. This requires superuser permissions.

    Declaration
    public Task ImportRemoteAsync(string path, uint oid, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    string path

    Path to read the file on the backend

    uint oid

    A preferred oid, or specify 0 if one should be automatically assigned

    CancellationToken cancellationToken

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

    Returns
    Type Description
    Task
    | Improve this Doc View Source

    OpenRead(uint)

    Opens a large object on the backend, returning a stream controlling this remote object. A transaction snapshot is taken by the backend when the object is opened with only read permissions. When reading from this object, the contents reflects the time when the snapshot was taken. Note that this method, as well as operations on the stream must be wrapped inside a transaction.

    Declaration
    public NpgsqlLargeObjectStream OpenRead(uint oid)
    Parameters
    Type Name Description
    uint oid

    Oid of the object

    Returns
    Type Description
    NpgsqlLargeObjectStream

    An NpgsqlLargeObjectStream

    | Improve this Doc View Source

    OpenReadAsync(uint, CancellationToken)

    Opens a large object on the backend, returning a stream controlling this remote object. A transaction snapshot is taken by the backend when the object is opened with only read permissions. When reading from this object, the contents reflects the time when the snapshot was taken. Note that this method, as well as operations on the stream must be wrapped inside a transaction.

    Declaration
    public Task<NpgsqlLargeObjectStream> OpenReadAsync(uint oid, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    uint oid

    Oid of the object

    CancellationToken cancellationToken

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

    Returns
    Type Description
    Task<><NpgsqlLargeObjectStream>

    An NpgsqlLargeObjectStream

    | Improve this Doc View Source

    OpenReadWrite(uint)

    Opens a large object on the backend, returning a stream controlling this remote object. Note that this method, as well as operations on the stream must be wrapped inside a transaction.

    Declaration
    public NpgsqlLargeObjectStream OpenReadWrite(uint oid)
    Parameters
    Type Name Description
    uint oid

    Oid of the object

    Returns
    Type Description
    NpgsqlLargeObjectStream

    An NpgsqlLargeObjectStream

    | Improve this Doc View Source

    OpenReadWriteAsync(uint, CancellationToken)

    Opens a large object on the backend, returning a stream controlling this remote object. Note that this method, as well as operations on the stream must be wrapped inside a transaction.

    Declaration
    public Task<NpgsqlLargeObjectStream> OpenReadWriteAsync(uint oid, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    uint oid

    Oid of the object

    CancellationToken cancellationToken

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

    Returns
    Type Description
    Task<><NpgsqlLargeObjectStream>

    An NpgsqlLargeObjectStream

    | Improve this Doc View Source

    Unlink(uint)

    Deletes a large object on the backend.

    Declaration
    public void Unlink(uint oid)
    Parameters
    Type Name Description
    uint oid

    Oid of the object to delete

    | Improve this Doc View Source

    UnlinkAsync(uint, CancellationToken)

    Deletes a large object on the backend.

    Declaration
    public Task UnlinkAsync(uint oid, CancellationToken cancellationToken = null)
    Parameters
    Type Name Description
    uint oid

    Oid of the object to delete

    CancellationToken cancellationToken

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

    Returns
    Type Description
    Task
    • Improve this Doc
    • View Source
    In This Article
    Back to top © Copyright 2023 The Npgsql Development Team