Skip to main content

TdxCloudStorage.TItemDownloadEvent Type

The nested procedural type of the file download progress tracking event.

Declaration

TItemDownloadEvent = procedure(Sender: TObject; const AItem: TdxCloudStorageItem; const APosition: Integer) of object;

Parameters

Name Type Description
Sender TObject

The cloud storage component that downloads a file.

AItem TdxCloudStorageItem

The resource metadata container that corresponds to a file downloaded from the connected server.

APosition Integer

The number of successfully downloaded bytes of the target file.

Remarks

The Sender parameter provides access to the cloud storage component that raised the download progress tracking event. To access the cloud storage component’s class members within a TItemDownloadEvent event handler, cast the parameter value to the TdxCloudStorage class.

The AItem parameter provides access to the downloaded file’s metadata container. To access its file-specific class members, cast the parameter value to the TdxCloudStorageFile class. For instance, you can attempt to identify the file size if the connected online storage service’s server can provide it. In most cases, the storage server cannot return the size of a file only if it is stored in a unique, service-specific format, such as a Google Sheets document.

The APosition parameter returns the number of successfully downloaded bytes of the target file. You can display this value in your application UI in various measurement units and calculate the download progress as a fraction or percentage:

 var
   AProgress: Integer; // The current file download progress (as a percentage)
   AFile: TdxCloudStorageFile;
//...
   AFile := TdxCloudStorageFile(AItem);
   if(AFile.FileSize <> -1) then // If the server provides the file's size
     AProgress := Round(APosition/AFile.FileSize * 100);

The OnItemDownload event references the TItemDownloadEvent nested procedural type.

See Also