TTMSFNCCloudFileConversion
Usage
The TTMSFNCCloudFileConversion
component is a wrapper around various file conversion services:
- Cloud Convert
- Convert IO
- Zamzar
Important notice
Due to current CORS issues from the Zamzar service, Zamzar is not available in TMS WEB Core
These services use an API Key. Click here for more information on how to retrieve these API Keys.
How to convert a file:
1. You can create a new conversion job in 3 different ways with the ConvertFile...
call, you can upload a file, use an url to the file or with a base64 encoded string.
2. When the service gives a response you will get a conversion job object.
3. As the service works asynchronous, you will need to call the GetJobDetails
method to get an update on the conversion;
4. When the status of the conversion job is successful, you can download the converted file to a stream or directly to a file.
5. In case there are multiple files some services will add the zip-file containing all. This is indicated with the CombinedZip
property.
Properties
Property name |
Description |
APIKey |
The API Key used for the corresponding service. |
ConvertJobs |
Collection of the different conversion jobs (TTMSFNCCloudFileConversionJob) that were created or retrieved. |
Methods
Method name |
Description |
ConvertFile(TTMSFNCUtilsFile, OutputFileFormat, JobCallBack) |
Method to get the supported languages used by the service |
ConvertFileFromBase64(Base64String, FileName, OutputFileFormat, JobCallBack) |
Method to translate single or multiple lines of text. |
ConvertFileFromURL(URL, OutputFileFormat, FileName, JobCallBack)) |
Method to detect the language of a single line of text. |
GetConvertJobs(All, NumberOfJobs, JobsCallBack) |
Retrieves the previous conversion jobs in the service. If all is set to false only the successful will be returned. |
GetConvertJobDetails(Job, JobCallBack) |
Updates the information on the conversion job. Necessary to call to retrieve the download url |
DownloadFileToStream(File, FileStreamCallBack) |
Retrieves the stream of the requested OutputFile (TTMSFNCCloudFileConversionFile) . This can be called when the Url of the file is retrieved. |
DownloadFileToFile(Path, File, FileCallBack) |
Saves the file of the requested OutputFile (TTMSFNCCloudFileConversionFile) . This can be called when the Url of the file is retrieved. |
CancelConvertJob(JobCallBack) |
Tries to cancel the conversion. |
GetConvertJobById(string): TTMSFNCCloudFileConversionJob |
Helper function to retrieve a converion job object by the id. |
GetConversionFileFormatFromString(string): FileFormat |
Helper function to convert as format string to the fileformat enumerator. |
GetFileFormatText(FileFormat): string |
Helper function to convert the fileformat to a string. |
GetFileFormatText(FileFormat): string |
Helper function to convert the status text to a string. |
ValidFileName(FileName): boolean |
Helper function to check if the filename is correctly filled in. An extension is required. |
Events
Event name |
Description |
OnConvertJobCancelled |
Event called when the method CancelConvertJob was called. |
OnConvertJobCreated |
Event called when one of the ConvertFile... methods is called to check if a new file conversion was started. |
OnFileDownloadedToFile |
Event called when a file was saved after DownloadFileToFile . |
OnFileDownloadedToStream |
Event called when the stream of a file is received after DownloadFileToStream . |
OnFileUploaded |
Event called when a file was uploaded after ConvertFile to the service. |
OnGetConvertJobs |
Event called when the GetConvertJobs method is called and the list of existing jobs is retrieved from the service. |
TTMSFNCCloudFileConversionJob
Properties
Property name |
Description |
Id |
A unique id to retrieve the conversion job. |
Name |
The file name of the conversion job. |
OutputFormat |
The format (TTMSFNCCloudFileConversionFileFormat ) to which the input file should be converted. |
OutputFiles |
A Collection of TTMSFNCCloudFileConversionFile with all of the output files. |
Status |
The status (TTMSFNCCloudFileConversionJobStatus ) of the conversion job. |
Methods
Method name |
Description |
GetDetails(JobCallBack) |
Updates the information on the conversion job. Necessary to call to retrieve the download url |
CancelConversion(JobCallBack) |
Tries to cancel the conversion. |
DownloadFileToStream(File, FileStreamCallBack) |
Retrieves the stream of the file. This can be called when the Url is retrieved. |
DownloadFileToFile(FilePath, FileCallBack) |
Saves the file to the path. This can be called when the OutputUrl is retrieved. |
DownloadAllFilesToFile(Directory, CombinedZip, FileCallBack) |
Saves the file to the path. This can be called when the OutputUrl is retrieved. |
GetConvertFileById(string): TTMSFNCCloudFileConversionFile |
Helper function to retrieve an output file object by the id. |
TTMSFNCCloudFileConversionFile
Properties
Property name |
Description |
Id |
A unique id to retrieve the file in the conversion job. |
Name |
The name of the file. |
Format |
The format (TTMSFNCCloudFileConversionFileFormat ) of the file. |
Url |
The url from which to download the file. |
Job |
The owner of the file. |
CombinedZip |
If there are multiple output files, some services add a zip file to download all of them in one. |
Methods
Method name |
Description |
DownloadFileToStream(FileStreamCallBack) |
Retrieves the stream of the file. This can be called when the Url is retrieved. |
DownloadFileToFile(FilePath, FileCallBack) |
Saves the file to the path. This can be called when the Url is retrieved. |