Back to Devexpress

TdxCloudStorageFileProgressCallback Type

vcl-dxcloudstorage-fc4fbe6a.md

latest1.8 KB
Original Source

TdxCloudStorageFileProgressCallback Type

The callback procedural type designed to track file upload and download progress.

Declaration

delphi
TdxCloudStorageFileProgressCallback = reference to procedure(const APosition: Int64; const ASize: Int64);

Parameters

NameTypeDescription
APositionInt64

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.

|

Remarks

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:

delphi
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);
cpp
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

dxCloudStorage Unit