Private SDK: Temporary File Storage
Discover effective strategies for implementing temporary file storage in your private SDK to optimize data handling and enhance performance.
Table of Contents
In distributed ESM deployments, an application cluster may consist of multiple servers, virtual machines, or containers. In such environments, temporary files stored on the local file system cannot be relied upon, as subsequent processing may be executed on a different compute node where those files are unavailable.
Typical use cases include:
- Staging files for the Import Engine (GDI)
- Exchanging large volumes of data between background processing tasks running on different compute nodes
- Sharing temporary artifacts between application components in a clustered environment
The Temporary File Storage service provides a consistent abstraction for:
- Creating and storing temporary files
- Accessing temporary files from any application node
- Automatically cleaning up expired temporary files
The service automatically selects the most appropriate storage backend and communication mechanism based on the deployment model. Depending on the environment, temporary files may be stored in
- Local file system
- Azure Storage Account
- S3-Compatible storage
The underlying access method (for example, direct file access or REST API) is selected automatically and is transparent to consumers of the service.
Advanced Temporary Storage Component
Supported starting from version: 26.2
Interface: Matrix42.StorageService.Contracts.ITempStorageService
PowerShell global variable: -
Methods
| Method | Description |
|---|---|
| UploadAsync |
Uploads a file and returns its newly generated URI. Uses the Rest API to upload the file content in streaming mode. Parameters:
|
| Download |
Downloads the content of a temporary file by its identifier. Parameters:
Returns:
|
| Download (by URL) |
Downloads the content of a temporary file by its URL. Parameters:
Returns:
|
| GetMetaInfo |
Gets the metadata for a temporary file. Parameters:
Returns: TempFileMetaInfo: The file metadata, or null if not found.
|
| Delete |
Gets the metadata for a temporary file. Parameters:
Returns: TempFileMetaInfo: The file metadata, or null if not found.
|
Examples
Use Temporary Storage in C# code
var storageService = ServiceLocator.Current.GetInstance<ITempStorageService>();
var downloadedFile = storageService.Download(sourceFile.LocationUrl) ?? storageService.DownloadFromWeb(sourceFile.LocationUrl);Lightweight Temporary Storage Component for Powershell
Supported starting from version: 26.2
Interface: Matrix42.StorageService.Contracts.ITempFileUploadService
Powershell global variable: $M42_TempFileService
Methods
| Method | Description |
|---|---|
| Upload |
Uploads a file to the Temporary File Storage and returns a unique file URI. The file is transferred using the REST API in streaming mode. Parameters:
|
| Upload From File |
Uploads an existing file from the local file system to the Temporary File Storage and returns a unique file URI. Parameters:
Returns:
|
| Download by File Identifier |
Downloads the content of a temporary file using its identifier. Parameters:
Returns:
|
| Download by File URI |
Downloads the content of a temporary file using its URI.. Parameters:
Returns: Returns a
|
Examples
Upload file from the PowerShell script
# Upload local file to Temp Storage and clean up in 30 mins
$TempFile=$M42_TempFileService.UploadFromFile("user.csv", "D:\temp\gdi\users.csv", 30)
# Store variable content to Temp Storage
$TempFile=$M42_TempFileService.Upload("user.csv", "some content")