Interface IFileManagerService
This interface has operations for file management (upload and download).
Syntax
public interface IFileManagerService
Remarks
Certain memoQ Server web service operations (such as IServerProjectService.ImportTranslationDocument for document import) require a file to be uploaded. IFileManagerInterface.BeginChunkedFileUpload and its related operations can be used to upload the file first, and then the file identifier returned by BeginChunkedFileUpload can be used to identify the uploaded file to be imported when calling IServerProjectServicedocument.ImportTranslationDocument.
There are other memoQ Server web service operations (such as IServerProjectServicedocument.ExportTranslationDocument for document export) that store the result on the memoQ Server in a file. The file identifier returned by these operations can be used to download the file using IFileManagerInterface.BeginChunkedFileDownload and its related operations.
Uploaded files and files created by web service operations (such as IServerProjectServicedocument.ExportTranslationDocument are not preserved for more than a few hours in the memoQ Server. Therefore, initiate processing operations (such as document import) immediately after file upload. It is also recommended to delete the uploaded file by calling DeleteFile if a file is no longer needed. For example after the processing (such as document import) has finished, and also after having downloaded the resulting file of a server operation (such as document export).
Methods
AddNextFileChunk(Guid, Byte[])
Performs the upload of the next file chunk. The operation should be called in turns to upload the next chunk of the file. It is important that the interval between two AddNextFileChunk calls (and the interval between the call of BeginChunkedFileUpload and the first call of AddNextFileChunk) is less than a minute or two. If the interval is larger, then the upload session times out on the server and reserved resources (such as the file handle) are released, the upload cannot continue.
Declaration
void AddNextFileChunk(Guid fileIdAndSessionId, byte[] fileData)
Parameters
Type | Name | Description |
---|---|---|
Guid | fileIdAndSessionId | The session id (guid) of the chunked file upload session created by BeginChunkedFileUpload. |
Byte[] | fileData | The bytes of the file chunk. |
Exceptions
Type | Condition |
---|---|
UnexpectedFault | An unexpected error occured; equivalent of an 501 'Internal server error' http result. |
GenericFault | The details within the fault identify the specific error. Thrown for expected business errors that have no specific faults. |
BeginChunkedFileDownload(Guid, Boolean, out String, out Int32)
Starts a new chunked file download session.
Declaration
Guid BeginChunkedFileDownload(Guid fileGuid, bool zip, out string fileName, out int fileSize)
Parameters
Type | Name | Description |
---|---|---|
Guid | fileGuid | The file identifier. |
Boolean | zip | This parameter is deprecated, the value will be ignored. |
String | fileName | Name or path of the file (output parameter). It's exact content depends on the operation that has created the file. |
Int32 | fileSize | Size of the file in bytes (output parameter). |
Returns
Type | Description |
---|---|
Guid | The session id (guid) of the newly started chunked file download session. It should be provided as first parameter for the GetNextFileChunk and EndChunkedFileDownload operations. |
Exceptions
Type | Condition |
---|---|
UnexpectedFault | An unexpected error occured; equivalent of an 501 'Internal server error' http result. |
GenericFault | The details within the fault identify the specific error. Thrown for expected business errors that have no specific faults. |
BeginChunkedFileUpload(String, Boolean)
Starts a new chunked file upload session.
Declaration
Guid BeginChunkedFileUpload(string fileName, bool isZipped)
Parameters
Type | Name | Description |
---|---|---|
String | fileName | Name or path of the file. This information is stored with the uploaded file. It can contain only characters that are valid on a Windows Operating System (e.g. '?', '' are not allowed). |
Boolean | isZipped | If set to true, the file is assumed to be a zipped file, therefore it is unzipped on the server after upload. |
Returns
Type | Description |
---|---|
Guid | The session id (guid) of the newly started chunked file upload session. It should be provided as first parameter for the AddNextFileChunk and EndChunkedFileUpload. This guid is also the file identifier, that can be used by other web service operations after the file upload session has been ended by calling EndChunkedFileUpload. |
Exceptions
Type | Condition |
---|---|
UnexpectedFault | An unexpected error occured; equivalent of an 501 'Internal server error' http result. |
GenericFault | The details within the fault identify the specific error. Thrown for expected business errors that have no specific faults. |
DeleteFile(Guid)
Deletes the file on the memoQ Server. Call to delete uploaded and server generated files as soon as possible if they are no longer needed.
Declaration
void DeleteFile(Guid fileGuid)
Parameters
Type | Name | Description |
---|---|---|
Guid | fileGuid | The identifier of the file to be deleted. |
Exceptions
Type | Condition |
---|---|
UnexpectedFault | An unexpected error occured; equivalent of an 501 'Internal server error' http result. |
GenericFault | The details within the fault identify the specific error. Thrown for expected business errors that have no specific faults. |
EndChunkedFileDownload(Guid)
Call to end the chunked file download session after downloading all file bytes by GetNextFileChunk. It is very important to call this method as soon as possible after downloading the last chunk of data to release server resources (such as the file handle).
Declaration
void EndChunkedFileDownload(Guid sessionId)
Parameters
Type | Name | Description |
---|---|---|
Guid | sessionId | The session id (guid) of the chunked file download session created by BeginChunkedFileDownload. |
Exceptions
Type | Condition |
---|---|
UnexpectedFault | An unexpected error occured; equivalent of an 501 'Internal server error' http result. |
GenericFault | The details within the fault identify the specific error. Thrown for expected business errors that have no specific faults. |
EndChunkedFileUpload(Guid)
Ends the chunked file upload session. Call to indicate to the memoQ Server that all chunks have been sent by calling AddNextFileChunk. It is very important to call this method as soon as possible after uploading the last chunk of data to release server resources (such as the file handle). If the uploaded file is zipped, then the unzipping is performed, and the function does not return until the unzipping of the file has finished.
Declaration
void EndChunkedFileUpload(Guid fileIdAndSessionId)
Parameters
Type | Name | Description |
---|---|---|
Guid | fileIdAndSessionId | The session id (guid) of the chunked file upload session created by BeginChunkedFileUpload. |
Exceptions
Type | Condition |
---|---|
UnexpectedFault | An unexpected error occured; equivalent of an 501 'Internal server error' http result. |
GenericFault | The details within the fault identify the specific error. Thrown for expected business errors that have no specific faults. |
GetNextFileChunk(Guid, Int32)
Performs the download of the next file chunk. The operation should be called in turns to download the next chunk of the file. It is important that the interval between two GetNextFileChunk calls (and the interval between the call of BeginChunkedFileDownload and the first call of GetNextFileChunk) is less than a minute or two. If the interval is larger, then the download session times out on the server and reserved resources (such as the file handle) are released, the download can not continue.
Declaration
byte[] GetNextFileChunk(Guid sessionId, int byteCount)
Parameters
Type | Name | Description |
---|---|---|
Guid | sessionId | The session id (guid) of the chunked file download session created by BeginChunkedFileDownload. |
Int32 | byteCount | The number of bytes to be returned. The actual number of bytes may be less then this if the amount of remaining file data is less. Therefore always check the number of bytes of the returned data. |
Returns
Type | Description |
---|---|
Byte[] | The file data requested. The actual number of bytes may be less then the requested amount if the amount of remaining file data is less. |
Exceptions
Type | Condition |
---|---|
UnexpectedFault | An unexpected error occured; equivalent of an 501 'Internal server error' http result. |
GenericFault | The details within the fault identify the specific error. Thrown for expected business errors that have no specific faults. |