设备文件类API

更新时间:2018-11-26 21:49:34

查询设备文件信息

定义描述

path 版本 描述
/industry/file/queryByFileName 1.0.0 根据文件名称查询文件信息

请求参数

名称 类型 必要 描述
productKey String 产品Key
deviceName String 设备名称
fileName String 文件名

请求示例

 private static ApiRequest buildRequest() throws UnsupportedEncodingException {
        String host = "api.link.aliyun.com";
        String path = "/industry/file/queryByFileName";

        JSONObject request = new JSONObject();
        //api版本,必填
        request.put("apiVer", "1.0.0");

        JSONObject params = new JSONObject();
        // api入参
        params.put("productKey", "a1Kk7RWl7F0");
        params.put("deviceName", "mZ0o7UJIlKVLSNHu0BMh");
        params.put("fileName", "one.jpg");

        JSONObject requestBody = new JSONObject();
        //请求唯一标识,必填
        requestBody.put("id", System.currentTimeMillis());
        //协议版本,固定值1.0
        requestBody.put("version", "1.0");
        //请求唯一标识,必填
        requestBody.put("request", request);
        //api入参结构体
        requestBody.put("params", params);


        System.out.println(requestBody.toJSONString());

        byte[] body = requestBody.toJSONString().getBytes("UTF-8");

        ApiRequest apiRequest = new ApiRequest(Scheme.HTTPS, Method.POST_BODY, host, path, body);
        apiRequest.getHeaders().put("accept", "application/json");

        return apiRequest;
    }

返回示例

{
    "code": 200,
    "data": [
        {
            "fileName": "README.md",
            "fileSize": 0,
            "fileUrl": "http://iotx-file-store-pre.oss-cn-shanghai.aliyuncs.com/device_file/71845BF3806B44B8A269F78D57EEFD66/mZ0o7UJIlKVLSNHu0BMh0010608100/README.md?Expires=1535107097&OSSAccessKeyId=LTAIRY3rx5dg2JBm&Signature=1WIAafKdkZ4Eb4NM%2BQ%2FjO3v1eVU%3D",
            "gmtUpload": 1535098005000,
            "productKey": "a1Kk7RWl7F0",
            "deviceName": "mZ0o7UJIlKVLSNHu0BMh",
            "fileStoreId": 6198
        }
    ],
    "id": "32f095b9-c01b-408c-9a27-7430bc50ec06"
}

批量查询设备文件信息

定义描述

path 版本 描述
/industry/file/batchQuery 1.0.0 批量获取设备文件列表

请求参数

名称
类型
必要
描述
productKey
String
产品Key
deviceName
String
设备名称
fileNames
JSON
文件名称列表,
例如:["name1","name2"]

请求示例

 private static ApiRequest buildRequest() throws UnsupportedEncodingException {
        String host = "api.link.aliyun.com";
        String path = "/industry/file/batchQuery";

        JSONObject request = new JSONObject();
        //api版本,必填
        request.put("apiVer", "1.0.0");

        JSONObject params = new JSONObject();
        // api入参
        params.put("productKey", "a1Kk7RWl7F0");
        params.put("deviceName", "mZ0o7UJIlKVLSNHu0BMh");

        List<String> files = Lists.newArrayList();
        files.add("one.jpg");
        files.add("two.jpg");

        params.put("fileNames", files);

        JSONObject requestBody = new JSONObject();
        //请求唯一标识,必填
        requestBody.put("id", System.currentTimeMillis());
        //协议版本,固定值1.0
        requestBody.put("version", "1.0");
        //请求唯一标识,必填
        requestBody.put("request", request);
        //api入参结构体
        requestBody.put("params", params);


        System.out.println(requestBody.toJSONString());

        byte[] body = requestBody.toJSONString().getBytes("UTF-8");

        ApiRequest apiRequest = new ApiRequest(Scheme.HTTPS, Method.POST_BODY, host, path, body);
        apiRequest.getHeaders().put("accept", "application/json");

        return apiRequest;
    }

返回示例

{
    "code": 200,
    "data": [
        {
            "fileName": "README.md",
            "fileSize": 0,
            "fileUrl": "http://iotx-file-store-pre.oss-cn-shanghai.aliyuncs.com/device_file/71845BF3806B44B8A269F78D57EEFD66/mZ0o7UJIlKVLSNHu0BMh0010608100/README.md?Expires=1535107298&OSSAccessKeyId=LTAIRY3rx5dg2JBm&Signature=LChn4Kqckv1qApbSNZEl2uaBf6c%3D",
            "gmtUpload": 1535098005000,
            "productKey": "a1Kk7RWl7F0",
            "deviceName": "mZ0o7UJIlKVLSNHu0BMh",
            "fileStoreId": 6198
        }
    ],
    "id": "64a4940a-d985-4e50-934e-8dfd8f5fa546"
}

分页查询设备文件列表

定义描述

path 版本 描述
/industry/file/pageQuery 1.0.0 分页查询设备上传的文件列表

请求参数

名称 类型 必要 描述
productKey String 产品Key
deviceName String 设备名称
currentPage Integer 当然页数,从1开始
pageSize Integer 每页大小,最大200.

请求示例

private static ApiRequest buildRequest() throws UnsupportedEncodingException {
        String host = "api.link.aliyun.com";
        String path = "/industry/file/pageQuery";

        JSONObject request = new JSONObject();
        //api版本,必填
        request.put("apiVer", "1.0.0");

        JSONObject params = new JSONObject();
        // api入参
        params.put("productKey", "a1Kk7RWl7F0");
        params.put("deviceName", "mZ0o7UJIlKVLSNHu0BMh");
        params.put("currentPage", 1);
        params.put("pageSize", 10);

        JSONObject requestBody = new JSONObject();
        //请求唯一标识,必填
        requestBody.put("id", System.currentTimeMillis());
        //协议版本,固定值1.0
        requestBody.put("version", "1.0");
        //请求唯一标识,必填
        requestBody.put("request", request);
        //api入参结构体
        requestBody.put("params", params);


        System.out.println(requestBody.toJSONString());

        byte[] body = requestBody.toJSONString().getBytes("UTF-8");

        ApiRequest apiRequest = new ApiRequest(Scheme.HTTPS, Method.POST_BODY, host, path, body);
        apiRequest.getHeaders().put("accept", "application/json");

        return apiRequest;
    }

返回示例

{
    "code": 200,
    "data": {
        "totalNum": 1,
        "items": [
            {
                "fileName": "README.md",
                "fileSize": 0,
                "fileUrl": "http://iotx-file-store-pre.oss-cn-shanghai.aliyuncs.com/device_file/71845BF3806B44B8A269F78D57EEFD66/mZ0o7UJIlKVLSNHu0BMh0010608100/README.md?Expires=1535107168&OSSAccessKeyId=LTAIRY3rx5dg2JBm&Signature=0rrSPixBSLpvwDO3Z9RTkiZPcSI%3D",
                "gmtUpload": 1535098005000,
                "productKey": "a1Kk7RWl7F0",
                "deviceName": "mZ0o7UJIlKVLSNHu0BMh",
                "fileStoreId": 6198
            }
        ]
    },
    "id": "5969201a-4456-4070-83d6-430c6cf8e552"
}

删除设备文件

定义描述

path 版本 描述
/industry/file/deleteByFileName 1.0.0 根据文件名称删除文件

请求参数

名称 类型 必要 描述
productKey String 产品Key
deviceName String 设备名称
fileName String 文件名称

请求示例

private static ApiRequest buildRequest() throws UnsupportedEncodingException {
        String host = "api.link.aliyun.com";
        String path = "/industry/file/deleteByFileName";

        JSONObject request = new JSONObject();
        //api版本,必填
        request.put("apiVer", "1.0.0");

        JSONObject params = new JSONObject();
        // api入参
        params.put("productKey", "a1Kk7RWl7F0");
        params.put("deviceName", "mZ0o7UJIlKVLSNHu0BMh");
        params.put("fileName", "one.jpg");

        JSONObject requestBody = new JSONObject();
        //请求唯一标识,必填
        requestBody.put("id", System.currentTimeMillis());
        //协议版本,固定值1.0
        requestBody.put("version", "1.0");
        //请求唯一标识,必填
        requestBody.put("request", request);
        //api入参结构体
        requestBody.put("params", params);


        System.out.println(requestBody.toJSONString());

        byte[] body = requestBody.toJSONString().getBytes("UTF-8");

        ApiRequest apiRequest = new ApiRequest(Scheme.HTTPS, Method.POST_BODY, host, path, body);
        apiRequest.getHeaders().put("accept", "application/json");

        return apiRequest;
    }

返回示例

{
    "code": 200,
    "data": "",
    "id": "7480f8a9-680e-4342-81c7-1d8f99bb005b"
}

批量删除设备文件

定义描述

path 版本 描述
/industry/file/batchDelete 1.0.0 根据文件名称列表批量删除文件

请求参数

名称
类型
必要
描述
productKey
String
产品Key
deviceName
String
设备名称
fileNames
JSON
文件名称列表
["fileA","fileB"]

请求示例

private static ApiRequest buildRequest() throws UnsupportedEncodingException {
        String host = "api.link.aliyun.com";
        String path = "/industry/file/batchDelete";

        JSONObject request = new JSONObject();
        //api版本,必填
        request.put("apiVer", "1.0.0");

        JSONObject params = new JSONObject();
        // api入参
        params.put("productKey", "a1Kk7RWl7F0");
        params.put("deviceName", "mZ0o7UJIlKVLSNHu0BMh");

        List<String> files = Lists.newArrayList();
        files.add("three.jpg");
        files.add("two.jpg");

        params.put("fileNames", files);

        JSONObject requestBody = new JSONObject();
        //请求唯一标识,必填
        requestBody.put("id", System.currentTimeMillis());
        //协议版本,固定值1.0
        requestBody.put("version", "1.0");
        //请求唯一标识,必填
        requestBody.put("request", request);
        //api入参结构体
        requestBody.put("params", params);


        System.out.println(requestBody.toJSONString());

        byte[] body = requestBody.toJSONString().getBytes("UTF-8");

        ApiRequest apiRequest = new ApiRequest(Scheme.HTTPS, Method.POST_BODY, host, path, body);
        apiRequest.getHeaders().put("accept", "application/json");

        return apiRequest;
    }

返回示例

{
    "code": 200,
    "data": "",
    "id": "7480f8a9-680e-4342-81c7-1d8f99bb005b"
}

results matching ""

    No results matching ""