Class ArchiveTempFileProvider
This class implements the ITempFileProvider interface and makes available temp file services. It uses the Document section in the config file to determine impersonation options and file path.
Implements
Inherited Members
Namespace: SuperOffice.CRM.Documents
Assembly: SoDataBase.dll
Syntax
[SoInject]
public class ArchiveTempFileProvider : ITempFileProvider
Constructors
ArchiveTempFileProvider(ILogger<ArchiveTempFileProvider>)
This class implements the ITempFileProvider interface and makes available temp file services. It uses the Document section in the config file to determine impersonation options and file path.
Declaration
public ArchiveTempFileProvider(ILogger<ArchiveTempFileProvider> logger)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger<ArchiveTempFileProvider> | logger |
Methods
CheckIfFileExistsAsync(string, CancellationToken)
Check if a named temporary file/storage area exists
Declaration
public Task<bool> CheckIfFileExistsAsync(string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | File name to check |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if such a file exists |
CreateFileAsync(string, CancellationToken)
Create a temporary 'file'
Declaration
public Task<string> CreateFileAsync(string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name to be used for later access. The actual key used by the implementation should also take into account the associate ID, since multiple concurrent users may use the same name, and that does not mean file sharing between users. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<string> |
CreateFileForAppendingAsync(string, CancellationToken)
Create a temporary 'file' for appending
Declaration
public Task<string> CreateFileForAppendingAsync(string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name to be used for later access. The actual key used by the implementation should also take into account the associate ID, since multiple concurrent users may use the same name, and that does not mean file sharing between users. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<string> |
DeleteFileAsync(string, CancellationToken)
Delete a temporary file
Declaration
public Task DeleteFileAsync(string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name identifying the file. See comments in the CreateFile method for more information on how file names are handled. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
ReadFileChunkAsync(string, long, byte[], CancellationToken)
Read a chunk of data from the file (random access read)
Declaration
public Task<int> ReadFileChunkAsync(string name, long filePosition, byte[] bufferToUpdate, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name identifying the file. See comments in the CreateFile method for more information on how file names are handled. |
| long | filePosition | Position in bytes, starting at 0, to start reading from |
| byte[] | bufferToUpdate | Data buffer to update. The length of this buffer is the maximum number of bytes that will be read |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<int> | Actual number of bytes read. If less than the length of the buffer, end-of-file is indicated |
ReadFileCompleteAsync(string, CancellationToken)
Make the complete content of the file available as a stream (sequential read)
Declaration
public Task<Stream> ReadFileCompleteAsync(string name, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name identifying the file. See comments in the CreateFile method for more information on how file names are handled. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<Stream> | Stream representing the entire current contents of the file |
WriteFileChunkAsync(string, long, byte[], CancellationToken)
Write a chunk of data to the file (random access write)
Declaration
public Task WriteFileChunkAsync(string name, long filePosition, byte[] bufferToWriteFrom, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name identifying the file. See comments in the CreateFile method for more information on how file names are handled. |
| long | filePosition | Position in bytes, starting at 0, that will be written to |
| byte[] | bufferToWriteFrom | Buffer to write; buffer length determines the size of the write operation |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
WriteFileCompleteAsync(string, Stream, CancellationToken)
Copy all information from DATA stream into the temp file represented by NAME, and close the stream when done.
Declaration
public Task WriteFileCompleteAsync(string name, Stream data, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Temp file name |
| Stream | data | Stream to read to the end. This stream is CLOSED after it has been read. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |