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
System.Object
NpgsqlLargeObjectManager
Namespace: Npgsql
Assembly: Npgsql.dll
Syntax
public class NpgsqlLargeObjectManager : object

Constructors

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

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
System.Boolean

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
System.Int32

Methods

Create(UInt32)

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
System.UInt32 preferredOid

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

Returns
Type Description
System.UInt32

The oid for the large object created

Exceptions
Type Condition
PostgresException

If an oid is already in use

CreateAsync(UInt32, 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)
Parameters
Type Name Description
System.UInt32 preferredOid

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

CancellationToken cancellationToken

Cancellation token.

Returns
Type Description
Task<System.UInt32>

The oid for the large object created

Exceptions
Type Condition
PostgresException

If an oid is already in use

ExportRemote(UInt32, 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
System.UInt32 oid

Oid of the object to export

System.String path

Path to write the file on the backend

ExportRemoteAsync(UInt32, 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)
Parameters
Type Name Description
System.UInt32 oid

Oid of the object to export

System.String path

Path to write the file on the backend

CancellationToken cancellationToken

Cancellation token.

Returns
Type Description
Task

ImportRemote(String, UInt32)

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
System.String path

Path to read the file on the backend

System.UInt32 oid

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

ImportRemoteAsync(String, UInt32, 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)
Parameters
Type Name Description
System.String path

Path to read the file on the backend

System.UInt32 oid

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

CancellationToken cancellationToken

Cancellation token.

Returns
Type Description
Task

OpenRead(UInt32)

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
System.UInt32 oid

Oid of the object

Returns
Type Description
NpgsqlLargeObjectStream

An NpgsqlLargeObjectStream

OpenReadAsync(UInt32, 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)
Parameters
Type Name Description
System.UInt32 oid

Oid of the object

CancellationToken cancellationToken

Cancellation token.

Returns
Type Description
Task<NpgsqlLargeObjectStream>

An NpgsqlLargeObjectStream

OpenReadWrite(UInt32)

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
System.UInt32 oid

Oid of the object

Returns
Type Description
NpgsqlLargeObjectStream

An NpgsqlLargeObjectStream

OpenReadWriteAsync(UInt32, 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)
Parameters
Type Name Description
System.UInt32 oid

Oid of the object

CancellationToken cancellationToken

Cancellation token.

Returns
Type Description
Task<NpgsqlLargeObjectStream>

An NpgsqlLargeObjectStream

Unlink(UInt32)

Deletes a large object on the backend.

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

Oid of the object to delete

UnlinkAsync(UInt32, CancellationToken)

Deletes a large object on the backend.

Declaration
public Task UnlinkAsync(uint oid, CancellationToken cancellationToken)
Parameters
Type Name Description
System.UInt32 oid

Oid of the object to delete

CancellationToken cancellationToken

Cancellation token.

Returns
Type Description
Task
Back to top Copyright © 2015-2017 Microsoft
Generated by DocFX