Interface ITempFileProvider
Interface defining a plugin that offers services for reading and writing temporary files.
Namespace: SuperOffice.CRM.Documents
Assembly: SuperOffice.Plugins.dll
Syntax
public interface ITempFileProvider : IPlugin
Remarks
Temporary files are used in several contexts - when transferring documents in chunks into and out of NetServer; when uploading a document to be saved through the Document dialog, and when handling mails and attachments.
The default implementation supplied with NetServer provides these services using temporary files, controlled by the Documents section in the config file with respect to path and impersonation. Alternative implementations, for instance using database or in-memory storage, are also possible. The term file is therefore not to be taken literally - though whatever implementation is actually used, the end result should support both sequential and random access, just like files.
Classes implementing this interface also need to be marked with the TempFileProviderAttribute attribute.
Methods
CheckIfFileExists(String)
Check if a named temporary file/storage area exists
Declaration
bool CheckIfFileExists(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | File name to check |
Returns
Type | Description |
---|---|
Boolean | True if such a file exists |
CreateFile(String)
Create a temporary 'file'
Declaration
string CreateFile(string name)
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. |
Returns
Type | Description |
---|---|
String |
DeleteFile(String)
Delete a temporary file
Declaration
void DeleteFile(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name identifying the file. See comments in the CreateFile(String) method for more information on how file names are handled. |
GetLength(String)
Get the current length in bytes of a temporary file
Declaration
long GetLength(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name identifying the file. See comments in the CreateFile(String) method for more information on how file names are handled. |
Returns
Type | Description |
---|---|
Int64 | Length of file in bytes; -1 if file does not exist |
ReadFileChunk(String, Int64, Byte[])
Read a chunk of data from the file (random access read)
Declaration
int ReadFileChunk(string name, long filePosition, byte[] bufferToUpdate)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name identifying the file. See comments in the CreateFile(String) method for more information on how file names are handled. |
Int64 | 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 |
Returns
Type | Description |
---|---|
Int32 | Actual number of bytes read. If less than the length of the buffer, end-of-file is indicated |
ReadFileComplete(String)
Make the complete content of the file available as a stream (sequential read)
Declaration
Stream ReadFileComplete(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name identifying the file. See comments in the CreateFile(String) method for more information on how file names are handled. |
Returns
Type | Description |
---|---|
Stream | Stream representing the entire current contents of the file |
WriteFileChunk(String, Int64, Byte[])
Write a chunk of data to the file (random access write)
Declaration
void WriteFileChunk(string name, long filePosition, byte[] bufferToWriteFrom)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name identifying the file. See comments in the CreateFile(String) method for more information on how file names are handled. |
Int64 | 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 |
WriteFileComplete(String, Stream)
(Over)write - not append - the complete content of the file (sequential write). Any previous content is lost
Declaration
void WriteFileComplete(string name, Stream data)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name identifying the file. See comments in the CreateFile(String) method for more information on how file names are handled. |
Stream | data | Stream to read data from |