Fetch Size of CKAsset in Cloud Kit

164 views Asked by At

Is it possible to fetch the file of a CKAsset before download it?

I'd like to alert the user if the file is very big and if is better to have a WIFI connected.

let queryOperation = CKQueryOperation(query: query)
queryOperation.zoneID = zone
queryOperation.desiredKeys = [CloudKitManager.ShareChat.ChatName.rawValue]

var records = [CKRecord]()
queryOperation.recordFetchedBlock = {record in records.append(record)}

In CloudKit Dashboard, in Asset details there is the file size, a work around is to save the file size and put it in a field.

1

There are 1 answers

0
Farhad Malekpour On

query for the asset, then use

asset.value(forKey: "size")