21.2. Features of handling files in the asynchronous mode and in the web client
Handling files in the asynchronous mode is available on the side of the client application only. In the general case, you should use synchronous methods for work on the server side and asynchronous ones for working on the client application side.
Let us consider an example of handling files in the asynchronous mode: deleting all files in the directory of temporary files. This action will look as the follows for the synchronous mode:
&AtClient Procedure Delete (Command) Try DeleteFiles(TempFilesDir(), GetClientAllFilesMask()); Report("Delete successful"); Exception // error handling is performed here ErrorDetails = ErrorInfo(); Message("An error occurred when performing a file operation: " + ErrorProcessing.BriefErrorDescription(ErrorDetails)); EndTry; EndProcedure
Asynchronous mode will look as follows:
&AtClient Async Procedure DeleteTemporaryFiles(Command) Try Await DeleteFilesAsync(Await TempFilesDirAsync(), GetClientAllFilesMask()); Report("Delete successful"); Exception // error handling is performed here ErrorDetails = ErrorInfo(); Message("An error occurred when performing a file operation: " + ErrorProcessing.BriefErrorDescription(ErrorDetails)); EndTry; EndProcedure
You should pay attention to the fact that almost all file operations are asynchronous. Even such simple actions as receiving a directory of temporary files. If an error occurs when executing file operations, it will be caught by Try ‑ Exception.
Handling files in the web client has some features:
- If you do not install plug-ins for handling files, in any browser, you have the methods available: GetFile(), BeginPutFile() and BeginPlacingFiles(). Capabilities of parameterization of the methods BeginPutFile() and BeginPuttingFiles().
The method BeginPutFile() (in the interactive mode) stops code execution in the 1C:Enterprise language in the thin and thick client, as opposed to the web client. The call of the callback procedure passed to theBeginPutFile() method will be performed after the method completion. To avoid behavior differences for thin and web clients, place the whole code to be executed after moving a file in the callback handler.
In web client, only asynchronous file operation methods are available. This behavior is not affected by the application property Modality use mode.5.1.6. Specifying compatibility properties
Installation of the file system extension gives more options for parameterization and asynchronous file operation methods. However, options for the synchronous file operation in the web client are unavailable in any operation mode.
The file system extension does not support HTTPS operation using the client certificate.
NOTE 1. Microsoft Core XML Services (MSXML), vs 4.0 or 6.0 is recommended to be used for the correct operation of the file system extension in the web browser Microsoft Internet Explorer.
NOTE 2. The file system extension for Microsoft Internet Explorer is installed to the directory %APPDATA%\1C\1СEWebExt\FileSystemExtIE.