iCloud.recordFetchFile()

Type Function
Return value none
Revision Release 2025.3714
Keywords iCloud, sync, storage, CloudKit, recordFetch
See also iCloud.recordFetchMultiple()
iCloud.recordQuery()
iCloudRecordEvent
iCloud.*

Overview

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().

Syntax

iCloud.recordFetchFile( params )
params (required)

Table. Table containing method-specific parameters — see the next section for details.

Parameter Reference

Valid keys for the params table include:

Example

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 ),
})