在工业平台中,获取临时oss授权,用来上传资质管理中相关的图片内容
路径 | /industry/qualification/oss/sts/get |
版本号 | 1.0.0 |
协议 | HTTPS |
请求方法 | POST |
是否需要用户身份鉴权 | 可选 |
超时时间 | 5000 |
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
appId | String | 是 | 应用的appId | |
index | Long | 是 | 1 | 图片的序列号,如果限制了至多上传10张图片,那么index的值是1~10 |
id | Long | 是 | 1001 | 资质管理中,对应的自有品牌和其他品牌的记录id |
suffix | String | 是 | "jpg"、"png"、"gif" | 图片后缀 |
type | String | 是 | 自有品牌=OWNBRAND,其他品牌=OTHERBRAND | 图片类型 |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
code | Int |
code |
|
data | JSON |
data |
|
accessKeyId | String |
构建ossClient时的accessKeyId |
|
securityToken | String |
构建ossClient时的securityToken |
|
accessKeySecret | String |
构建ossClient时的accessKeySecret |
|
endpoint | String |
构建ossClient时的endpoint |
|
uploadUrl | String |
oss接口putObject的URL入参 |
|
expiration | String |
临时授权的有效时间 |
|
message | String |
message |
示例
请求示例
// https://github.com/aliyun/iotx-api-gateway-client
IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();
ioTApiClientBuilderParams.setAppKey("你的<AppKey>");
ioTApiClientBuilderParams.setAppSecret("你的<AppSecret>");
SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);
IoTApiRequest request = new IoTApiRequest();
// 设置请求ID
String uuid = UUID.randomUUID().toString();
String id = uuid.replace("-", "");
request.setId(id);
// 设置API版本号
request.setApiVer("1.0.0");
// 设置参数
request.putParam("appId", "value0");
request.putParam("index", value1");
request.putParam("id", value2");
request.putParam("suffix", value3");
request.putParam("type", value4");
// 如果需要,设置headers
Map<String, String> headers = new HashMap<String, String>(8);
// headers.put("你的<header", "你的<value>");
// 设置请求参数域名, path, request, isHttps, headers
ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/industry/qualification/oss/sts/get", request, true, headers);
System.out.println(
"response code = " + response.getCode()
+ " response = " + new String(response.getBody(), "UTF-8")
+ " headers = " + response.getHeaders().toString()
);
正常返回示例
JSON
格式
{
"id": "4de2c367-c1db-417c-aa15-8c585e595d92",
"code": 200,
"message": null,
"localizedMsg": null,
"data": {
"accessKeyId":"STS.yted",
"accessKeySecret":"BMMhxVddd",
"endpoint":"oss-cn-hangzhou.aliyuncs.com",
"expiration":"2020-05-04T15:36:42Z",
"securityToken":"CAIS7AJ1q6Ft5B2yfSjIr5bUI",
"uploadUrl":"http://iotx-industry.oss-cn-hangzhou.aliyuncs.com"
}
}
异常返回示例
JSON
格式
{
"id": "37f7e5fa-d6a5-4efe-8abf-5bf23dca6284",
"code": 403,
"message": "request forbidden.",
"localizedMsg": "请求被禁止",
"data": null
}
错误码
HttpCode | 错误码 | 错误信息 | 描述 |
---|---|---|---|
500 | 500 | Internal Error | Internal Error |
503 | 503 | Service Unavailable | Service Unavailable |
403 | 403 | Request Limited | Request Limited |
401 | 401 | Empty Signature | Empty Signature |
400 | 400 | Request Format Error | Request Format Error |
200 | 20003 | Find Backend Error | Find Backend Error |
200 | 20004 | Backend Service Error | Backend Service Error |
200 | 20055 | Backend Service Invalid | Request Format Error |
200 | 20056 | Hsf Invoke Timeout | Hsf Invoke Timeout |
200 | 401 | Request Authorized Error | Request Authorized Error |
200 | 403 | Request Forbidden | Request Forbidden |
200 | 500 | Server Error | Server Error |
200 | 500 | server error. | 系统错误 |
200 | 403 | request forbidden. | 请求被禁止 |
200 | 460 | request parameter error. | 请求参数错误 |
200 | 500 | server error. | 系统错误 |
200 | 460 | request parameter error. | 请求参数错误 |
200 | 460 | request forbidden | 请求被禁止 |
200 | 1009 | SQL invoke error | SQL 执行出错 |