vcl-dxcloudstorage-fc4fbe6a.md
The callback procedural type designed to track file upload and download progress.
TdxCloudStorageFileProgressCallback = reference to procedure(const APosition: Int64; const ASize: Int64);
| Name | Type | Description |
|---|---|---|
| APosition | Int64 |
Returns the number of downloaded or uploaded bytes.
| | ASize | Int64 |
Returns the size of a downloaded or uploaded file, in bytes. The parameter returns -1 if the server cannot return the downloaded file’s size.
|
Implement a TdxCloudStorageFileProgressCallback procedure to track file upload or download progress. The following code example calculates download progress as a percentage you can display in your application UI:
var
AProgress: Integer; // File download progress as a percentage
//...
if(ASize <> -1) then // If the server provides the file size
AProgress := Round(APosition/ASize * 100);
int AProgress; // File download progress as a percentage
TdxCloudStorageFile *AFile;
//...
AFile = dynamic_cast<TdxCloudStorageFile*>(AItem);
if(AFile->FileSize != -1) { // If the server provides the file size
AProgress = round((float)APosition/ASize * 100);
}
The AProgressCallback parameter in the cloud storage component’s DownloadFile and UploadFile functions references the TdxCloudStorageFileProgressCallback procedural type.
See Also