Downloading and uploading a collection of files is achieved by first compressing into a single file, called an archive, and then transferring the archive from one machine to the other. In this article, we will focus on the compression of a collection of files into a single archive, and on the expansion of such an archive into a collection of files.
The AIMMS core does not provide zipping and unzipping functionality natively; but
- Windows 10 and Windows 11 provide the powershell commands Compress-Archive and Expand-Archive
- Most Linux distributions, including the Linux distribution used on the AIMMS Cloud, provide zip. The use of zip is illustrated here
This can be leveraged using the :any:`Execute` procedure of AIMMS, for instance to create a zip archive as follows:
if AimmsStringConstants('Platform') = "Linux" then
Execute( "zip", "-r " + sp_destinationFile + " " + sp_folderName , wait:1) ;
else
Execute( "powershell \"Compress-Archive -Path "+ sp_folderName+" -DestinationPath "+sp_destinationFile+"\"", wait:1);
endif ;
and to unpack such a zip archive into files as follows:
if AimmsStringConstants('Platform') = "Linux" then
Execute( "unzip", sp_fileName + " -d " + sp_destinationFolderName , wait:1) ;
else
Execute( "powershell \"Expand-Archive -Path "+ sp_fileName+" -DestinationPath "+sp_destinationFolderName+"\"", wait:1);
endif ;
The above is captured in an example project that can be obtained via the download:
:download:`AIMMS 24.2 project download <model/ZipUnzip.zip>`
This project has the following interface:
The buttons have the following actions:
buttonZipDemo
: Activates the procedure to zip, containing thezip
andpowerShell Compress-Archive
example above.Prepare download
: Download the zip file created by thebuttonZipDemo
buttonUnzipDemo
: Activates the procedure to unzip, containing theunzip
andpowerShell Expand-Archive
example above.buttonOverviewCopiedFiles
: Lists all files in the project folder, including the files expanded from the archive bybuttonUnzipDemo
- :doc:`Run executable files <../../Articles/114/114-execute>`
- Upload widget
- Download widget
- Datalake storage download: dex::dls::DownloadFile
- Datalake storage upload: dex::dls::UploadFile
.. spelling:word-list:: powershell