# Class NpgsqlLargeObjectManager

Namespace
  Npgsql

Assembly
  Npgsql.dll

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

    [Obsolete("NpgsqlLargeObjectManager allows manipulating PostgreSQL large objects via publicly available PostgreSQL functions (lo_read, lo_write); call these yourself directly.")]
    public class NpgsqlLargeObjectManager

Inheritance
  object
  NpgsqlLargeObjectManager

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

## Constructors

### NpgsqlLargeObjectManager(NpgsqlConnection)

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

    public NpgsqlLargeObjectManager(NpgsqlConnection connection)

#### Parameters

`connection` NpgsqlConnection

## Properties

### 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.

    public bool Has64BitSupport { get; }

#### Property Value

bool

### MaxTransferBlockSize

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

    public int MaxTransferBlockSize { get; set; }

#### Property Value

int

## Methods

### 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.

    public uint Create(uint preferredOid = 0)

#### Parameters

`preferredOid` uint

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

#### Returns

uint

  The oid for the large object created

#### Exceptions

PostgresException

  If an oid is already in use

### 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.

    public Task<uint> CreateAsync(uint preferredOid, CancellationToken cancellationToken = default)

#### Parameters

`preferredOid` uint

  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 None.

#### Returns

Task<uint>

  The oid for the large object created

#### Exceptions

PostgresException

  If an oid is already in use

### ExportRemote(uint, string)

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

    public void ExportRemote(uint oid, string path)

#### Parameters

`oid` uint

  Oid of the object to export

`path` string

  Path to write the file on the backend

### ExportRemoteAsync(uint, string, CancellationToken)

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

    public Task ExportRemoteAsync(uint oid, string path, CancellationToken cancellationToken = default)

#### Parameters

`oid` uint

  Oid of the object to export

`path` string

  Path to write the file on the backend

`cancellationToken` CancellationToken

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

#### Returns

Task

### 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.

    public void ImportRemote(string path, uint oid = 0)

#### Parameters

`path` string

  Path to read the file on the backend

`oid` uint

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

### 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.

    public Task ImportRemoteAsync(string path, uint oid, CancellationToken cancellationToken = default)

#### Parameters

`path` string

  Path to read the file on the backend

`oid` uint

  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 None.

#### Returns

Task

### 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.

    public NpgsqlLargeObjectStream OpenRead(uint oid)

#### Parameters

`oid` uint

  Oid of the object

#### Returns

NpgsqlLargeObjectStream

  An NpgsqlLargeObjectStream

### 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.

    public Task<NpgsqlLargeObjectStream> OpenReadAsync(uint oid, CancellationToken cancellationToken = default)

#### Parameters

`oid` uint

  Oid of the object

`cancellationToken` CancellationToken

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

#### Returns

Task<NpgsqlLargeObjectStream>

  An NpgsqlLargeObjectStream

### 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.

    public NpgsqlLargeObjectStream OpenReadWrite(uint oid)

#### Parameters

`oid` uint

  Oid of the object

#### Returns

NpgsqlLargeObjectStream

  An NpgsqlLargeObjectStream

### 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.

    public Task<NpgsqlLargeObjectStream> OpenReadWriteAsync(uint oid, CancellationToken cancellationToken = default)

#### Parameters

`oid` uint

  Oid of the object

`cancellationToken` CancellationToken

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

#### Returns

Task<NpgsqlLargeObjectStream>

  An NpgsqlLargeObjectStream

### Unlink(uint)

Deletes a large object on the backend.

    public void Unlink(uint oid)

#### Parameters

`oid` uint

  Oid of the object to delete

### UnlinkAsync(uint, CancellationToken)

Deletes a large object on the backend.

    public Task UnlinkAsync(uint oid, CancellationToken cancellationToken = default)

#### Parameters

`oid` uint

  Oid of the object to delete

`cancellationToken` CancellationToken

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

#### Returns

Task