Generates the URL and details of a device list file that you want to upload to Object Storage Service (OSS). When you create a static update batch, you can specify devices that you want to update in a device list file.

Requirements

  • A device list file contains the names of devices. Separate multiple device names with line feeds. Each line contains only one device name. A device list file must be in the CSV format. The maximum size of a device list file is 5 MB.
  • Each device list file can contain up to 10,000 names for the devices in a product that is related to an update package. If the number of device names in a device list file exceeds the limit, an error occurs when you use the file to create a static update batch.

Description

This operation can be used with other operations to upload a device list file. Procedure:

1. Call this operation to generate the information of a device list file that you want to upload to OSS.

The response parameters of this API operation include:

The following request parameters of the OSS PostObject operation that is used to upload the device list file: Key, AccessKeyId, Signature, and Policy.

2. Use an OSS SDK to call the PostObject operation to upload the device list file within 1 minute after a response is returned. For more information about sample code, see the "Usage of response parameters" section in this topic.

Note The parameter information that is returned by this operation is valid for 1 minute. You must upload the device list file within 1 minute.

3. After you upload the device list file, call the CreateOTAStaticUpgradeJob operation of IoT Platform to create a static update batch within 60 minutes.

If you upload device list files but you do not call the CreateOTAStaticUpgradeJob operation to create a static update batch, the system automatically deletes the uploaded files. The system deletes files on a regular basis.

QPS limits

Each Alibaba Cloud account can run up to 10 queries per second (QPS).

Note The RAM users of an Alibaba Cloud account share the quota of the Alibaba Cloud account.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes GenerateDeviceNameListURL

The operation that you want to perform. Set the value to GenerateDeviceNameListURL.

IotInstanceId String No iot-cn-0pp1n8t****

The ID of the instance. You can view the instance ID on the Overview page in the IoT Platform console.

Notice
  • If your instance has an ID, you must specify the ID for this parameter. Otherwise, the call fails.
  • If your instance has no Overview page or ID, you do not need to configure this parameter.

For more information, see Overview.

In addition to the preceding operation-specific request parameters, you must configure common request parameters when you call this operation. For more information, see Common request parameters.

Response parameters

Parameter Type Example Description
Code String iot.system.SystemException

The error code returned if the call fails. For more information, see Error codes.

Data Struct

The information returned if the call is successful. For more information, see the following parameters:

AccessKeyId String cS8uRRy54Rsz****

The AccessKey ID of the bucket owner.

The OSS bucket stores the file.

FileUrl String https://iotx-ota.oss-cn-shanghai.aliyuncs.com/ota/65dfcda0473be29836dfde585472****/ck2nfzljo00023g7kysg0****.csv

The URL of the file that is stored in OSS.

After the device list file is uploaded, this parameter is used to call the CreateOTAStaticUpgradeJob operation to create a static update batch.

Host String https://iotx-ota.oss-cn-shanghai.aliyuncs.com

The endpoint of OSS.

Key String ota/65dfcda0473be29836dfde585472****/ck2nfzljo00023g7kysg0****.csv

The full path of the file in OSS. You can call the OSS PostObject operation to upload the file to OSS.

ObjectStorage String OSS

The type of the object storage. Default value: OSS.

Policy String eyJleHBpcmF****

The parameter that is used by OSS to verify form fields for the request.

Signature String v6lViO4FBvfquajQjg20K5hK****

The signature that is calculated based on AccessKeySecret and Policy. When you call an OSS operation, OSS uses the signature information to verify the POST request.

UtcCreate String 2019-11-04T06:21:54.607Z

The time when the URL of the file that you want to upload was generated. The time is displayed in UTC.

ErrorMessage String A system exception occurred.

The error message returned if the call fails.

RequestId String 74C2BB8D-1D6F-41F5-AE68-6B2310883F63

The ID of the request.

Success Boolean true

Indicates whether the call was successful.

  • true: The call was successful.
  • false: The call failed.

Usage of response parameters

When you call the OSS PostObject operation to upload the file to OSS, specify the values of the parameters that are returned by this operation for the request parameters of the PostObject operation.

The following sample code that is written in Java shows how to upload the device list file to OSS.

  • Add the following dependencies to the pom.xml file:
<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.5.3</version>
</dependency>

<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpmime</artifactId>
  <version>4.5.10</version>
</dependency>
            
  • Sample code:
public static boolean postObject(String key,
                                  String host,
                                  String policy,
                                  String ossAccessKeyId,
                                  String signature,
                                  String data) throws IOException {
  CloseableHttpClient httpClient = HttpClients.createDefault();
  HttpPost uploadFile = new HttpPost(host);

  MultipartEntityBuilder builder = MultipartEntityBuilder.create();
  builder.addTextBody("key", key, ContentType.TEXT_PLAIN);
  builder.addTextBody("policy", policy, ContentType.TEXT_PLAIN);
  builder.addTextBody("ossAccessKeyId", ossAccessKeyId, ContentType.TEXT_PLAIN);
  builder.addTextBody("signature", signature, ContentType.TEXT_PLAIN);
  builder.addTextBody("success_action_status", "200", ContentType.TEXT_PLAIN);
  builder.addBinaryBody("file", data.getBytes());

  HttpEntity multipart = builder.build();
  uploadFile.setEntity(multipart);
  CloseableHttpResponse response = httpClient.execute(uploadFile);

  if (response.getStatusLine().getStatusCode() == 200) {
    return true;
  }

  return false;
}
            

Examples

Sample requests

https://iot.cn-shanghai.aliyuncs.com/?Action=GenerateDeviceNameListURL
&<Common request parameters>

Sample success responses

XML format

<GenerateDeviceNameListURLResponse>
      <Data>
            <Policy>eyJleHBpcmF****</Policy>
            <FileUrl>https://iotx-ota.oss-cn-shanghai.aliyuncs.com/ota/65dfcda0473be29836dfde585472****/ck2nfzljo00023g7kysg0****.csv</FileUrl>
            <UtcCreate>2019-11-04T06:21:54.607Z</UtcCreate>
            <AccessKeyId>cS8uRRy54Rsz****</AccessKeyId>
            <Signature>v6lViO4FBvfquajQjg20K5hK****</Signature>
            <ObjectStorage>OSS</ObjectStorage>
            <Host>https://iotx-ota.oss-cn-shanghai.aliyuncs.com</Host>
            <Key>ota/65dfcda0473be29836dfde585472****/ck2nfzljo00023g7kysg0****.csv</Key>
      </Data>
      <RequestId>74C2BB8D-1D6F-41F5-AE68-6B2310883F63</RequestId>
      <Success>true</Success>
</GenerateDeviceNameListURLResponse>

JSON format

{
    "Data": {
        "Policy": "eyJleHBpcmF****",
        "FileUrl": "https://iotx-ota.oss-cn-shanghai.aliyuncs.com/ota/65dfcda0473be29836dfde585472****/ck2nfzljo00023g7kysg0****.csv",
        "UtcCreate": "2019-11-04T06:21:54.607Z",
        "AccessKeyId": "cS8uRRy54Rsz****",
        "Signature": "v6lViO4FBvfquajQjg20K5hK****",
        "ObjectStorage": "OSS",
        "Host": "https://iotx-ota.oss-cn-shanghai.aliyuncs.com",
        "Key": "ota/65dfcda0473be29836dfde585472****/ck2nfzljo00023g7kysg0****.csv"
    },
    "RequestId": "74C2BB8D-1D6F-41F5-AE68-6B2310883F63",
    "Success": true
}