Files
To be able to access files from file fields in data groups via an OData service, the corresponding file field must be added to the service. Since Intrexx provides additional metadata fields for file fields, a field with the complex data type "IxFile" is automatically added to the entity type for each file field. In addition to the file, this also contains metadata, such as the file name, type, and size. Furthermore, three functions are available to access files and manage them. There are two possibilities to access files, which are described in the following.
Embedding files in OData feeds
The first option is the direct embedding of a file content as a Base64-encoded binary string in an OData feed or entry. This is the simplest method to access a file, by providing it directly with the result of an OData request. The connector for OData can extract the file content and save it locally as a file or transfer it to another file field in a target file group and display the file in the browser using the file selection element. It is also possible to save and update individual files via the file selection. The disadvantage of this approach is that only one file can be provided for each file field. In the case of multiple file fields, this is always the first file, though a new file will always be added when saving. Also, the performance of the service will be significantly negatively impacted, since the file must first be completely loaded into the RAM in order to encode or decode it. For this reason, this method should only be used for smaller files.
OData functions for files
A significantly more flexible and resource-saving possibility to access files using OData is by using the ""upFile"" functions, which are automatically available in every Intrexx OData service. They can be used to save and request files, and they provide full support for multiple file fields in Intrexx. The single disadvantage of the functions is that the file controls in Intrexx do not support this approach, which means that uploading and downloading files in Intrexx web applications will need to be realized on a project-specific basis with JavaScript or Groovy. The Intrexx OData service offers the following functions to manage files:
- upFileList
The upFileList function returnsa list of all files in a file field. The following parameters are expected:
recId: The primary key of the data record with the file field.
fieldGuid: The field GUID of the file field.
- upFileAction
These functions can be used to perform operations on multiple file fields. The following parameters are expected::
recId: The primary key of the data record with the file field.
fileId: The ID of the file.
fieldGuid: The field GUID of the file field.
operation: The file operation to be executed (either delete, moveUp, moveDown, moveTop, refreshMetadata, refreshOrder).
- upFileDownload
Returns the content of a file as a Base64-encoded string.the following parameters are expected:
recId: The primary key of the data record with the file field.
fileId: The ID of the file.
fieldGuid: The field GUID of the file field.
- upFileResource - upload
Enables a stream-based upload of a file.this is the fastest and most resource-friendly method of transferring files to the service. The following parameters are expected for the uploadFile method:
recId: The primary key of the data record with the file field.
fieldGuid: The field GUID of the file field.
fileName: The file name.
contentType: The content type of the file.
- upFileResource - download
Enables a stream-based download of a file.this is the fastest and most resource-saving method of accessing files. The following parameters are expected for the downloadFile method:
recId: The primary key of the data record with the file field.
fileId: The ID of the file.
fieldGuid: The field GUID of the file field.
disposition (optional): The content disposition header type (either inline or attachment).