You can upload device files to IoT Platform over MQTT. This reduces the overhead of hardware resources and development costs. This article describes how to configure Link SDK for C to upload device files to IoT Platform.

Prerequisites

Background information

Process

The application program of the device uploads files to IoT Platform over MQTT .

  • You must establish an MQTT connection. For more information, see Overview.
  • The following figure shows the process. In this example, the ./demos/mqtt_upload_basic_demo.capplication program is used.1

Usage notes

  • Take note of the following naming conventions for files:
    • Each file name can contain digits, letters, underscores (_), and periods (.).
    • Each file name must start with a digit or letter.
    • Each file name can be up to 100 bytes in length.
  • You can upload multiple files at a time.
  • An IoT Platform instance can store up to 1 GB of files.
  • A device can upload up to 1,000 files for storage.
  • The size of a single file can be up to 16 MB.
  • When a device initiates a request to upload a file, IoT Platform implements one of the following policies based on the file name.
    • If no file with the same name exists in IoT Platform, a file uploading task is created.
    • If a file with the same name exists in IoT Platform, an operation is performed based on the specified policy. For more information about the sample code and description, see Step 4: Initiate a request to upload files.
      Processing policy (conflictStrategy) Description
      overwrite This policy is used by default. If you use this policy, IoT Platform deletes the existing file and retains only the newly uploaded file.
      append After the device initiates the file uploading request, IoT Platform returns the information about the existing file with the same name. In this case, you can perform the following operations on the device:
      • If the uploading process of the file in IoT Platform is not completed, you can continue to upload the on-premises file.
        Note IoT Platform retains the files that are not completely uploaded for only 24 hours.
      • If the uploading process of the file in IoT Platform is completed, you can change the policy or raname the on-premises file. Then, upload the file again.
      reject IoT Platform returns an error code indicating that the file already exists and rejects the request to upload the on-premises file.

Examples

  • For more information about examples, see Sample code.