A2v10 Platform documentation
UK


Files

The files object describes the commands for working with downloaded files that are available at the current endpoint. Object property names represent the command names. Each property represents an object of the following structure:

Usually used with the UploadFile control. The command is specified in the Url property of the control.


Properties of the object

Name Type Description
type enum Obligatory. File operation type:
parse The file parsing. If a model is specified, the file is stored in a database. If the model is empty, the parsing result is simply returned to the client. You must specify a parse property. You can also specify the locale property for the text files.
Example of the data import.
sql Direct storage of the raw file data in the database. The model must be specified.
azureBlob Save the file in the Azure Storage. The container property must be specified. The name of the source (connection string) is specified in the azureSource property. If not specified, equals to "AzureStorage".
clr Calling the .NET object method. You must specify the clrType property. Learn more....
parse enum Obligatory for parse operation. Format of the file being parsed.
csv, dbf, xml Type of the file for analysis.
xlsx, excel Microsoft Excel files parsing. Only .xlsx format is supported.
auto Automatic format determination depending on the file extension.
Example of the data import.
locale string Optional. The locale for the file parsing. A text string representing the language and, optionally, the country. For example: "uk", "uk-UA" for Ukraine. Used in particular to parse numbers (decimal separator, thousands separator). If not specified, the standard view (a dot as a decimal separator) is used.
source string Optional. Data source. If not specified, taken from the parent item.
schema string Optional. Name of the sql schema. If not specified, taken from the parent item.
model string Name of the model. If not specified, taken from the parent item. If it is equal to an empty line, the model is not stored in the database, but simply returned to the client.
container string Obligatory for the azureBlob type. The name of the container in Azure Storage.
azureSource string Only for the azureBlob ype. Source (connection string name) for Azure Storage. If not specified, equals to "AzureStorage".
clrType string Required for the clr type. A string describing the build and the .NET type.
async boolean Only for the clr type. Asynchronous execution of the clr-command.
parameters object Object, the static parameters that are passed to the stored model update procedure. The property name is the name of the parameter, the value is the value of the parameter.
imageCompress object Controls image compression when they are uploaded to the server. For JPEG files only.
quality File quality (0..100). 0-minimum, 100-maximum. The actual value of 40-50 does not lead to a significant deterioration in image quality.
threshold The minimum value of the file size (in megabytes) for which the compression will be applied. If the file size is smaller, it is saved "as is".

Parse operation

The operation parses the resulting file (according to the format specified in the parse property) and presents it as a table. If a model is specified, the system attempts to save the resulting table to the database.

Saving the model is performed as follows:

  • The procedure for obtaining metadata ({source}: [{schema}].[{model}.Metadata]) is called. This procedure should return one record with a description of one table. The table name is predefined - Rows.
  • The matching of the fields of the received file and the metadata table is performed, and the corresponding table type is filled in.
  • The update procedure ({source}: [{schema}].[{model}.Update]) is called. The table obtained at the previous step is passed to it. The following parameters are passed to the procedure:
    • Standard parameters (@TenantId, @UserId).
    • Parameters passed to the url.
    • Parameters from the parameters property.
    • @Rows (readonly) - table type. Table data.
  • The model obtained as a result of the saved procedure is simply returned to the client.

If the value of the model property is equal to an empty string (""), then no additional actions are performed with the result of file parsing. The resulting table is simply returned to the client as an object with a single Rows property that contains an array of records for the source file.

Sql operation

This operation simply saves the resulting file in the database as a byte array (vabinary(max type)). If the imageCompress parameter is specified, the file will (possibly) be pre-compressed. To do this, call the stored procedure {source}: [{schema}].[{model}.Update]. The following parameters are passed to it (the same as in the case of saving attachments):

Name Type Description
@UserId bigint Сurrent user ID.
@TenantId bigint Tenant ID (only in a multitenant environment).
@Name nvarchar(255) File name (without path).
@Mime nvarchar(255) MIME-type of the file.
@Stream varbinary(max) File data (just bytes without conversion).

Note that the parameter names are fixed!

Clr operation

The type must implement the IInvokeTarget interface. Learn more....

The name, MIME type, and (Stream) of the received file are passed to the method.