Sending a File to the Device

The device manager provides a method to send a file from either the global or thing file storage in Device Cloud.

In this procedure, the thing key of the device manager is as follows, where deviceId is the value in the device_id file in the configuration directory:

Python Agent

deviceId-device_manager_py

C Agent

deviceId-device-manager

By default, the Python device manager waits 60 seconds for the file download to finish. If you send large files, you may need to change the value of the download_timeout attribute in the iot.cfg file.

You need your user name, password, and URL for Device Cloud.

The device manager on the device must be connected to Device Cloud.

The device manager must have permission to read and write to the directory to which you want to send the file.

  1. In your browser's address bar, type the URL you were given when you received your Device Cloud account, and then on the Sign In page, type your user name and password in the boxes.
  2. On the LaunchPad, click Development Tools.
  3. To upload the file from your computer to the file store in the Device Cloud, do one of the following on the Management Portal:
    OptionDescription

    Global File Store

    1. Click Developer, and then click Files.

    2. On the Files page, click New file.

    Thing File Store

    1. Click Things, click the View icon of the device manager thing, and then select the Files tab.

    2. Click Add file.

  4. In the Add File window, click Attach File, and select the file you want to upload from the file system on your computer.
  5. (Optional) Select the Public check box.

    If you do not select Public, only you can access the file.

  6. Click Upload.

    The file appears in the list of files on the page.

  7. If you are not on the thing details page, click Things, and then click the View icon of the device manager thing.
  8. On the thing details page, select the Methods tab, and then click Send Files.
  9. (Optional) In the file_name box in the Send Files window, type the name of the file you uploaded in step 4.

    If you do not specify a file name, the file appears on the device with the same name used in the file storage in Device Cloud.

  10. In the file_path box, type the directory and file name you want to store the file as on the device.

    You can use a different file name from the name of the file you uploaded. If you did not specify a file name in the previous step, you must specify the file name used in the file storage in Device Cloud.

    You can specify a path as follows:

    • Python agent: relative to the runtime_dir/download, where runtime_dir is the value of the runtime_dir attribute specified in the iot.cfg file

    • C agent: relative to /var/lib/iot/download directory

    • the full path

  11. If you uploaded the file to the global file store in step 3, select the use_global_store check box.
  12. Click Execute.

    The Output box shows double quotes ("") to indicate that the device received the file successfully and stored it in the directory with the file name you specified. The device manager creates the directory you specified if it does not exist.