Updated on 2022-02-22 GMT+08:00

Uploading Files

This API is used to upload files to OBS. During the file upload, threads are blocked. They are blocked until the file upload is completed. The root directory (location of the target OBS bucket) to which the files are uploaded is configured by the user for each device on the Huawei HiLens console (for details, see User Guide > Managing Data). If the user does not configure the root directory for a device, the files fail to be uploaded.

  • API calling

    hilens.upload_file(key, filepath, mode)

    For firmware versions later than 1.0.6, use hilens.upload_file_to_obs(key, filepath, mode).

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Type

    Description

    key

    Yes

    Character string

    Path on OBS to which files are uploaded. Only the OBS file path is needed, for example, test/output.jpg, so do not add the website information.

    Note that names of the two directories in key cannot start or end with periods (.) or contain consecutive slashes, such as //.

    filepath

    Yes

    Character string

    Absolute path of the file to be uploaded.

    mode

    Yes

    Character string

    Upload mode. The options are write (overwrite) and append (add).

  • Return value

    If the operation is successful, 0 is returned. Otherwise, the operation fails.