Table of Contents

Class DocumentService

Namespace
The.Documents
Assembly
Instagile.dll

Functions to load and store files or images.

public sealed class DocumentService
Inheritance
DocumentService
Inherited Members

Constructors

DocumentService(IDocumentStore, IServices, ILogger<DocumentService>, ILogger)

Functions to load and store files or images.

public DocumentService(IDocumentStore documentStore, IServices services, ILogger<DocumentService> serviceLogger, ILogger storeLogger)

Parameters

documentStore IDocumentStore
services IServices
serviceLogger ILogger<DocumentService>
storeLogger ILogger

Methods

AddAccessRules(IPrincipal?, CancellationToken?, params IReadOnlyList<NewAccessRule>)

public Task AddAccessRules(IPrincipal? principal, CancellationToken? cancellationToken, params IReadOnlyList<NewAccessRule> newRules)

Parameters

principal IPrincipal
cancellationToken CancellationToken?
newRules IReadOnlyList<NewAccessRule>

Returns

Task

CreateFile(Guid, DocumentAccessAssertion)

Access an existing document given its known ID

public FileDocument CreateFile(Guid id, DocumentAccessAssertion access)

Parameters

id Guid
access DocumentAccessAssertion

Returns

FileDocument

CreateImage(Guid, DocumentAccessAssertion)

Access an existing document given its known ID

public ImageDocument CreateImage(Guid id, DocumentAccessAssertion access)

Parameters

id Guid
access DocumentAccessAssertion

Returns

ImageDocument

UploadFileAsync(Stream, string, string, DocumentAccessRule, bool, IPrincipal?, CancellationToken?, IProgress<long>?)

Create a new document from a stream

public Task<FileDocument> UploadFileAsync(Stream data, string originalFilename, string mimeType, DocumentAccessRule rule, bool disposeStream = true, IPrincipal? principal = null, CancellationToken? cancellationToken = null, IProgress<long>? progress = null)

Parameters

data Stream
originalFilename string
mimeType string
rule DocumentAccessRule
disposeStream bool
principal IPrincipal
cancellationToken CancellationToken?
progress IProgress<long>

Returns

Task<FileDocument>

Remarks

This will dispose of the stream you pass in, unless disposeStream:=False is specified.

UploadFileAsync(Stream, string, DocumentAccessRule, bool, IPrincipal?, CancellationToken?, IProgress<long>?)

Create a new document from a stream, using a MIME type determined from the filename.

public Task<FileDocument> UploadFileAsync(Stream data, string originalFilename, DocumentAccessRule rule, bool disposeStream = true, IPrincipal? principal = null, CancellationToken? cancellationToken = null, IProgress<long>? progress = null)

Parameters

data Stream
originalFilename string
rule DocumentAccessRule
disposeStream bool
principal IPrincipal
cancellationToken CancellationToken?
progress IProgress<long>

Returns

Task<FileDocument>

Remarks

This will dispose of the stream you pass in, unless disposeStream:=False is specified.

UploadFileAsync(string, string, DocumentAccessRule, IPrincipal?, CancellationToken?, IProgress<long>?)

Create a new document from the filesystem

public Task<FileDocument> UploadFileAsync(string localPath, string mimeType, DocumentAccessRule rule, IPrincipal? principal = null, CancellationToken? cancellationToken = null, IProgress<long>? progress = null)

Parameters

localPath string
mimeType string
rule DocumentAccessRule
principal IPrincipal
cancellationToken CancellationToken?
progress IProgress<long>

Returns

Task<FileDocument>

UploadFileAsync(string, DocumentAccessRule, IPrincipal?, CancellationToken?, IProgress<long>?)

Create a new document from the filesystem, using a MIME type determined from the filename

public Task<FileDocument> UploadFileAsync(string localPath, DocumentAccessRule rule, IPrincipal? principal = null, CancellationToken? cancellationToken = null, IProgress<long>? progress = null)

Parameters

localPath string
rule DocumentAccessRule
principal IPrincipal
cancellationToken CancellationToken?
progress IProgress<long>

Returns

Task<FileDocument>

UploadImageAsync(Stream, string, string, int, int, DocumentAccessRule, bool, IPrincipal?, CancellationToken?, IProgress<long>?)

Create a new image from a stream

public Task<ImageDocument> UploadImageAsync(Stream data, string originalFilename, string mimeType, int width, int height, DocumentAccessRule rule, bool disposeStream = true, IPrincipal? principal = null, CancellationToken? cancellationToken = null, IProgress<long>? progress = null)

Parameters

data Stream
originalFilename string
mimeType string
width int
height int
rule DocumentAccessRule
disposeStream bool
principal IPrincipal
cancellationToken CancellationToken?
progress IProgress<long>

Returns

Task<ImageDocument>

Remarks

This will dispose of the stream you pass in, unless disposeStream:=False is specified.

UploadImageAsync(Stream, string, DocumentAccessRule, bool, IPrincipal?, CancellationToken?, IProgress<long>?)

Create a new image from a stream, using a MIME type and dimensions determined from the data.

public Task<ImageDocument> UploadImageAsync(Stream data, string originalFilename, DocumentAccessRule rule, bool disposeStream = true, IPrincipal? principal = null, CancellationToken? cancellationToken = null, IProgress<long>? progress = null)

Parameters

data Stream
originalFilename string
rule DocumentAccessRule
disposeStream bool
principal IPrincipal
cancellationToken CancellationToken?
progress IProgress<long>

Returns

Task<ImageDocument>

Remarks

This will dispose of the stream you pass in, unless disposeStream:=False is specified. Loads the whole image in order to determine dimensions and MIME type.

UploadImageAsync(string, string, int, int, DocumentAccessRule, IPrincipal?, CancellationToken?, IProgress<long>?)

Store a new image from the filesystem.

public Task<ImageDocument> UploadImageAsync(string localPath, string mimeType, int width, int height, DocumentAccessRule rule, IPrincipal? principal = null, CancellationToken? cancellationToken = null, IProgress<long>? progress = null)

Parameters

localPath string
mimeType string
width int
height int
rule DocumentAccessRule
principal IPrincipal
cancellationToken CancellationToken?
progress IProgress<long>

Returns

Task<ImageDocument>

UploadImageAsync(string, DocumentAccessRule, IPrincipal?, CancellationToken?, IProgress<long>?)

Store a new image from the filesystem, using a MIME type and dimensions determined from the data.

public Task<ImageDocument> UploadImageAsync(string localPath, DocumentAccessRule rule, IPrincipal? principal = null, CancellationToken? cancellationToken = null, IProgress<long>? progress = null)

Parameters

localPath string
rule DocumentAccessRule
principal IPrincipal
cancellationToken CancellationToken?
progress IProgress<long>

Returns

Task<ImageDocument>

Remarks

Loads the whole image in order to determine dimensions and MIME type.

UploadThumbnailAsync(ImageMetadata, Stream, int, int, DocumentAccessAssertion, bool, IPrincipal?, CancellationToken?, IProgress<long>?)

Set the thumbnail for an existing image

public Task<ImageDocument> UploadThumbnailAsync(ImageMetadata thumbnailFor, Stream data, int width, int height, DocumentAccessAssertion access, bool disposeStream = true, IPrincipal? principal = null, CancellationToken? cancellationToken = null, IProgress<long>? progress = null)

Parameters

thumbnailFor ImageMetadata
data Stream
width int
height int
access DocumentAccessAssertion
disposeStream bool
principal IPrincipal
cancellationToken CancellationToken?
progress IProgress<long>

Returns

Task<ImageDocument>

Remarks

This will dispose of the stream you pass in, unless disposeStream:=False is specified.