Get File¶
Get the information of a file. This API is only available if 2.3 Cumulative Update 3 has been applied to your environment. For the full change list of 2.3 Cumulative Update 3, see Cumulative Update 3.
Operation Permissions¶
Required Authorization |
Required Operation Permission |
---|---|
Asset |
Read |
Request Format¶
GET https://{integration-address}/connect-service/v2.1/files?action=getFileInfo
Note
{integration-address}: The gateway address of message integration service. Log in to the EnOS Management Console and find it in Help > Environment Information.
Request Parameters (URI)¶
Note
Use one of the following methods to specify the asset:
Include
assetId
in the requestInclude
productKey
+deviceKey
in the request
Name |
Location (Path/Query) |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|---|
orgId |
Query |
Mandatory |
String |
The organization ID which the asset belongs to. How to get orgId>> |
fileUri |
Query |
Mandatory |
String |
The URI of the file. Format: |
category |
Query |
Mandatory |
String |
The type of the file to be downloaded. The value |
assetId |
Query |
Optional (See Note above) |
String |
The asset ID. How to get assetID>> |
productKey |
Query |
Optional (See Note above) |
String |
The product key. To be used with |
deviceKey |
Query |
Optional (See Note above) |
String |
The device key. To be used with |
Request Parameters (Header)¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
apim-accesstoken |
Mandatory |
String |
The access token obtained via token authentication. For more information, see Get Access Token |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
FileMetaDto Struct |
The file metadata information. For more information, see FileMetaDto Struct |
FileMetaDto Struct ¶
Name |
Data Type |
Description |
---|---|---|
orgId |
String |
The organization ID which the asset belongs to. |
category |
String |
The type of the file to be downloaded. |
fileUri |
String |
The URI of the file. |
originalFilename |
String |
The file name. |
fileSize |
Integer |
The file size. |
md5 |
String |
The MD5 of the file. |
signMethod |
String |
The signature algorithm for the file. |
sign |
String |
The file signature. |
createTime |
Long |
The time when the file is created. |
Samples¶
Request Sample¶
https://{integration-address}/connect-service/v2.1/files?action=getFileInfo&orgId=yourOrgId&fileUri=yourFileUri&category=feature&assetId=yourAssetId
method: GET
requestHeader: {
"apim-accesstoken":"yourAccessToken"
}
Response Sample¶
{
"code": 0,
"msg": "OK",
"requestId": "6a02a5a5-49f0-4df1-b364-496ad2079033",
"data": {
"orgId": "yourOrgId",
"category": "feature",
"fileUri": "yourFileUri",
"originalFilename": "file.txt",
"fileSize": 123,
"md5": "md5value",
"signMethod": "md5",
"sign": "fileSig",
"createTime": 1648694084000
}
}
Java SDK Sample¶
import com.envisioniot.enos.iot_http_integration.FileCategory;
import com.envisioniot.enos.iot_http_integration.HttpConnection;
import com.envisioniot.enos.iot_http_integration.dto.FileMetaDto;
import com.envisioniot.enos.iot_http_integration.message.*;
import com.envisioniot.enos.iot_mqtt_sdk.core.exception.EnvisionException;
import com.envisioniot.enos.sdk.data.DeviceInfo;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class GetFileInfoSample {
// EnOS Token Server URL and HTTP Broker URL, which can be obtained from Environment Information page in EnOS Console
static final String TOKEN_SERVER_URL = "https://ag-beta1.eniot.io";
static final String BROKER_URL = "https://iot-http-integration-beta1.eniot.io";
// EnOS Application AccessKey and SecretKey, which can be obtain in Application Registration page in EnOS Console
static final String APP_KEY = "yourAppKey";
static final String APP_SECRET = "yourAppSecret";
// Device credentials, which can be obtained from Device Details page in EnOS Console
static final String ORG_ID = "yourOrgId";
static final String ASSET_ID = "yourAssetId";
static final String PRODUCT_KEY = "yourProductKey";
static final String DEVICE_KEY = "yourDeviceKey";
public static void main(String[] args) throws EnvisionException {
// Construct a http connection
HttpConnection connection = new HttpConnection.Builder(
BROKER_URL, TOKEN_SERVER_URL, APP_KEY, APP_SECRET, ORG_ID)
.build();
DeviceInfo deviceInfo = new DeviceInfo().setAssetId(ASSET_ID);
// DeviceInfo deviceInfo = new DeviceInfo().setKey(PRODUCT_KEY,DEVICE_KEY);
// fileUri is an enos scheme file uri
String fileUri = "enos-connect://file.txt";
try {
FileInfoResponse rsp = connection.getFileInfo(deviceInfo, fileUri, FileCategory.FEATURE);
FileMetaDto data = rsp.getData();
} catch (EnvisionException e) {
e.printStackTrace();
}
}
}