Sending a File to Device Cloud in C
A client application can send a file from any location on the device to which it has read access and add it to the global file storage or the file storage of a thing in Device Cloud.
The file_name parameter is optional. If you do not specify it, the file name in the Device Cloud storage matches the name of the file you uploaded.
To upload the contents of a directory, specify the name of the directory in the file_path parameter. It is stored in Device Cloud as an archive.
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 send the file to the Device Cloud global file storage or the thing-specific file storage
-
maximum time to wait for the file transfer to complete
You must have initialized your application (see Initializing Your C Application).
To send files, the application must be connected to Device Cloud.
The application must have read access to the specified file and directory on the device.
When the application calls the function, the file appears in Device Cloud in the storage location as specified in the global field of the options parameter. If a file with the same name exists in the storage location, it is overwritten.