Retrieving a File from Device Cloud in C
A client application can retrieve a file from the global file storage or the file storage of a thing in Device Cloud and store it in any device location to which it has write access.
The file_name parameter is optional. If you do not specify it, the file name on the device matches the name of the file you downloaded from the Device Cloud storage.
Your application can specify a callback function for the agent to call periodically during the file transfer. The callback can implement progress monitoring and perform any additional processing as needed. When you register the callback function, you can specify user data to pass to the callback function. The data is not sent to Device Cloud or used by the agent.
In the options parameter of the API, you can specify additional, optional information, including the following:
-
whether to retrieve the file from the Device Cloud global file storage or the thing-specific file storage
-
maximum time to wait for the file transfer to complete
To retrieve files, the application must be connected to Device Cloud.
The application must have write access to the specified directory.
The file must exist in the Device Cloud file storage from which you want to retrieve it.
When the application calls the function, the file is retrieved from the storage location in Device Cloud as specified in the flags field of the options parameter and stored in the specified directory on the device. If the file already exists, it is overwritten.