0% found this document useful (0 votes)
20 views6 pages

memoQ File Management API Guide

ws DOCUMENTATION

Uploaded by

Pablo Estrada
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

memoQ File Management API Guide

ws DOCUMENTATION

Uploaded by

Pablo Estrada
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

9/12/24, 1:04 PM Interface IFileManagerService | WS API

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 [Link] for
document import) require a file to be uploaded. [Link] 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
[Link].

There are other memoQ Server web service operations (such as


[Link] 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 [Link] and its related operations.

Uploaded files and files created by web service operations (such as


[Link] 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
([Link] created by BeginChunkedFileUpload.
dotnet/api/[Link])

[Link] 1/6
9/12/24, 1:04 PM Interface IFileManagerService | WS API

Type Name Description

Byte fileData The bytes of the file chunk.


([Link]
dotnet/api/[Link])
[]

Exceptions

Type Condition

UnexpectedFault An unexpected error occured; equivalent of an 501 'Internal server


([Link] error' http result.
.html)

GenericFault The details within the fault identify the specific error. Thrown for
([Link] expected business errors that have no specific faults.
l)

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 fileSiz
e)

Parameters
Type Name Description

Guid fileGuid The file identifier.


([Link]
et/api/[Link])

Boolean zip This parameter is deprecated, the value will be ignored.


([Link]
et/api/[Link])

String fileName Name or path of the file (output parameter). It's exact
([Link] content depends on the operation that has created the file.
et/api/[Link])

Int32 fileSize Size of the file in bytes (output parameter).


([Link]
et/api/system.int32)

Returns
Type Description

Guid The session id (guid) of the newly started chunked file download session. It
([Link] should be provided as first parameter for the GetNextFileChunk and
com/dotnet/api/system EndChunkedFileDownload operations.
.guid)

[Link] 2/6
9/12/24, 1:04 PM Interface IFileManagerService | WS API
Exceptions
Type Condition

UnexpectedFault An unexpected error occured; equivalent of an 501 'Internal server


([Link] error' http result.
.html)

GenericFault The details within the fault identify the specific error. Thrown for
([Link] expected business errors that have no specific faults.
l)

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
([Link] file. It can contain only characters that are valid on a Windows
om/dotnet/api/[Link] Operating System (e.g. '?', '' are not allowed).
ring)

Boolean isZipped If set to true, the file is assumed to be a zipped file, therefore it is
([Link] unzipped on the server after upload.
om/dotnet/api/system.b
oolean)

Returns

Type Description

Guid The session id (guid) of the newly started chunked file upload session. It should be
([Link] provided as first parameter for the AddNextFileChunk and EndChunkedFileUpload. This
[Link]/dot guid is also the file identifier, that can be used by other web service operations after the
net/api/system. file upload session has been ended by calling EndChunkedFileUpload.
guid)

Exceptions
Type Condition

UnexpectedFault An unexpected error occured; equivalent of an 501 'Internal server


([Link] error' http result.
.html)

GenericFault The details within the fault identify the specific error. Thrown for
([Link] expected business errors that have no specific faults.
l)

[Link] 3/6
9/12/24, 1:04 PM Interface IFileManagerService | WS API

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 ([Link] fileGuid The identifier of the file to be deleted.

Exceptions

Type Condition

UnexpectedFault An unexpected error occured; equivalent of an 501 'Internal server


([Link] error' http result.
.html)

GenericFault The details within the fault identify the specific error. Thrown for
([Link] expected business errors that have no specific faults.
l)

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
([Link] created by BeginChunkedFileDownload.
tnet/api/[Link])

Exceptions

Type Condition

UnexpectedFault An unexpected error occured; equivalent of an 501 'Internal server


([Link] error' http result.
.html)

GenericFault The details within the fault identify the specific error. Thrown for
([Link] expected business errors that have no specific faults.
l)

[Link] 4/6
9/12/24, 1:04 PM Interface IFileManagerService | WS API

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
([Link] created by BeginChunkedFileUpload.
dotnet/api/[Link])

Exceptions

Type Condition

UnexpectedFault An unexpected error occured; equivalent of an 501 'Internal server


([Link] error' http result.
.html)

GenericFault The details within the fault identify the specific error. Thrown for
([Link] expected business errors that have no specific faults.
l)

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
([Link] BeginChunkedFileDownload.
[Link]/dotnet/ap
i/[Link])

Int32 byteCount The number of bytes to be returned. The actual number of bytes may be
([Link] less then this if the amount of remaining file data is less. Therefore always
[Link]/dotnet/ap check the number of bytes of the returned data.
i/system.int32)

[Link] 5/6
9/12/24, 1:04 PM Interface IFileManagerService | WS API
Returns

Type Description

Byte The file data requested. The actual number of bytes may be less then the
([Link] requested amount if the amount of remaining file data is less.
tnet/api/[Link])
[]

Exceptions

Type Condition

UnexpectedFault An unexpected error occured; equivalent of an 501 'Internal server


([Link] error' http result.
.html)

GenericFault The details within the fault identify the specific error. Thrown for
([Link] expected business errors that have no specific faults.
l)

[Link] 6/6

Common questions

Powered by AI

The file identifier returned by chunked file upload (`BeginChunkedFileUpload`) and download (`BeginChunkedFileDownload`) operations serves as a session ID that uniquely identifies the file throughout the upload or download process. This identifier is crucial for subsequent operations, such as adding or retrieving file chunks with `AddNextFileChunk` or `GetNextFileChunk`, and ending the session with `EndChunkedFileUpload` or `EndChunkedFileDownload`. Moreover, in the context of file upload, this identifier can be used by other web service operations, such as document import or export, allowing them to reference the file once the upload session is closed .

The IFileManagerService interface ensures data integrity during chunked upload and download operations by employing strict protocol measures. During upload, each chunk is associated with a session ID, allowing for consistent tracking and sequence management. The system requires each `AddNextFileChunk` to be called in a timely manner to prevent session timeouts, ensuring that each part of the file is uploaded sequentially and without interruption. On the download side, `GetNextFileChunk` fetches data in defined byte counts and similarly relies on timely calls to maintain session validity. Such session-based approaches ensure that each chunk is processed correctly, avoiding data corruption due to mismatched or missing segments. Furthermore, the immediate call to end sessions, like `EndChunkedFileUpload` and `EndChunkedFileDownload`, helps cement the transfer completion by finalizing resource allocation and processing tasks such as optional unzipping, thereby safeguarding the integrity of transferred data .

The role of exceptions in the file operations of IFileManagerService is critical for maintaining system robustness and error handling. The two main types of exceptions, `UnexpectedFault` and `GenericFault`, handle unexpected and specific business errors, respectively. `UnexpectedFault` points to severe issues like internal server errors, indicating unpredicted failures that need immediate investigation. Meanwhile, `GenericFault` deals with expected errors that can occur due to predictable scenarios, allowing the system to handle these gracefully without crashing. These exceptions help in diagnosing and managing issues efficiently, ensuring the system remains robust by preventing it from failing completely during file operations and aiding in logging detailed error information for debugging purposes .

The significance of session management in `BeginChunkedFileUpload` and `BeginChunkedFileDownload` lies in its ability to organize and coordinate file transfers effectively. A session ID, generated from these functions, acts as a unique key that manages the lifecycle of a specific file operation, defining how subsequent actions relate to it, such as chunk uploads or downloads. This association ensures that each file operation is encapsulated and traceable, enabling consistent tracking of progress and error handling, and preventing potential conflicts between simultaneous transfers. Furthermore, session management allows resources to be allocated precisely, and sessions ensure that uploads or downloads occur within controlled intervals, optimizing server resource use and securing data integrity .

Timeout management is crucial in the file chunking mechanisms of IFileManagerService because it ensures the continuity and successful completion of file upload and download sessions. If the intervals between consecutive calls, such as between `AddNextFileChunk` for uploads or `GetNextFileChunk` for downloads, exceed one to two minutes, the session may time out. This results in the server releasing reserved resources, like the file handle, thus terminating the session and rendering the continuation of the upload or download impossible. Such timeouts can lead to incomplete file transfers, data loss, or the need to restart the process, which could be costly in terms of time and resources .

Not ending a chunked file upload or download session promptly after transferring all file bytes can lead to several negative impacts. Primarily, server resources such as file handles remain occupied unnecessarily, which can cause bottlenecks, reduced performance, and limitations in handling concurrent sessions. This can escalate into failed operations due to server overload and resource contention. Additionally, failure to end sessions might lead to suffixing data integrity risks if the system believes operations are still in progress and doesn't finalize the transfers. It further introduces potential security vulnerabilities by keeping resources open longer than necessary. Prompt session ending ensures graceful resource deallocation and system efficiency .

Breaking down file operations into smaller chunks using the IFileManagerService interface is primarily done to manage large files efficiently and ensure uninterrupted data transfer across potentially unreliable networks. Chunking helps in handling low bandwidth scenarios by transferring manageable portions of data, reducing the impact of network latency or interruptions. It also allows for better resource allocation on servers, as sessions can be managed and resources released quickly after each chunk. Additionally, chunking reduces the risk of complete data loss due to failure during the transfer process, since only the differing chunks need retransmission instead of the entire file. This method is robust for operations involving large data sets that may not fit into memory or exceed size limits of transactional processes .

The IFileManagerService interface handles file uploads and downloads using a chunking mechanism to support large file transfers. The process starts with the `BeginChunkedFileUpload`, which initiates a session and returns a session ID that is used to identify the file throughout the upload process. Each file chunk is uploaded using multiple calls to `AddNextFileChunk`, which require the session ID and the file data. It's important to maintain intervals of less than one or two minutes between calls to prevent timeouts. Once all chunks are uploaded, `EndChunkedFileUpload` is called to release server resources and perform any additional processing, such as unzipping if required. On the download side, `BeginChunkedFileDownload` initiates a download session and returns a session ID to be used with subsequent calls to `GetNextFileChunk`, which should also be called in intervals of less than one or two minutes. The download process is completed with `EndChunkedFileDownload` to release resources. Files are not preserved for long, so it's crucial to complete processing soon after file operations and to delete unnecessary files using `DeleteFile` .

Deleting files on the memoQ Server as soon as they are no longer needed is recommended because uploaded files and files created by web service operations are not preserved for more than a few hours. Keeping unnecessary files on the server can occupy valuable resources and potentially lead to inefficiencies or storage limitations. Moreover, files are subject to be automatically removed after a short period, possibly disrupting any delayed operations. Thus, it's not only a resource management strategy but also crucial for maintaining the correct implementation flow by preventing reliance on temporary server-stored files. Prompt deletion helps in maintaining an efficient and effective server operation environment by freeing up resources for new processes .

The deprecated component in the file download process of IFileManagerService is the `zip` boolean parameter in the `BeginChunkedFileDownload` method. Although the parameter is present, its value is ignored, indicating that any functionality associated with it has been phased out. The implications of this deprecation are that developers must adjust any logic that relied on server-side unzipping during downloads. Since the parameter is not used, any existing processes that depended on its functionality may require reworking to handle archives on the client side, influencing how downloads are managed and possibly impacting performance or processing steps .

You might also like