Type Function Return value none Revision Release 2025.3721 Keywords iCloud, sync, storage, CloudKit, recordFetch See also iCloud.recordFetchMultiple() iCloud.recordQuery() iCloudRecordEvent iCloud.*
Use this method to fetch and download a single asset from Cloudkit from a single key with progress
To get a complete single record see iCloud.recordFetch().
iCloud.recordFetchFile( params )
Table. Table containing
Valid keys for the params table include:
recordName — Required string value representing the identifier for the record.
fieldKey — Required string value representing the field for the asset you want to download.
pathForFile — Required string value representing where you want to save the file via a string absolute path, please use system.pathForFile()
listener — Required listener function to be invoked with an iCloudFileEvent.
zoneName — Optional string value indicating the record’s zone name.
zoneOwner — Optional string value indicating the record’s zone owner.
database — Optional string value indicating the record’s database.
containerId — Optional string value indicating a specific iCloud Container in which the record is contained. Do not pass this parameter if you have only one iCloud Container associated with your app.
local json = require( "json" )
local iCloud = require "plugin.iCloud"
-- Listener function to handle the fetch request
local function fetchResults( event )
if event.record then
print( "Record is: ", json.prettify( event.record:table() ) )
else
print( "Record not fetched!" )
end
end
iCloud.recordFetchFile({
listener = function( event )
print("File event")
if(event.status == "progress")then
print(event.progress)
else if(event.status == "complete")then
local image = display.newImage( "image.png", system.DocumentsDirectory )
end
end,
fieldKey = "assetNameHere",
database = "public",
recordName = "testFile123",
pathForFile = system.pathForFile( "image.png", system.DocumentsDirectory ),
})