Skip to content

IoT File Client for Java

Introduction

The IoT File Java client allows you to manage files related to entity instances.

Refer to IoT File Service for more information about the service.

Hint

In the IoT context, assets are referred to as entity and aspects as propertyset.

File Operations

Client name: FileServiceClient

Create or Update a File

Create or update a file for an asset with the provided content in the specified path.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
FileServiceClient fileServiceClient = FileServiceClient.builder()
                                            .mindsphereCredentials(credentials)
                                            .restClientConfig(config)
                                            .build();

try {
  fileServiceClient.putFile(bytesArray, entityId, filePath, ifMatch, timestamp, description, type);
} catch (MindsphereException e) {
  // Exception handling
}

Read a File

Read a file for an asset from the specified path. The GET method is used for the API call.

1
2
3
4
5
6
7
8
//Construct FileServiceClient object as shown above

byte[] fileData;
try {
    fileData = fileServiceClient.getFile(entityId, filepath, ifNoneMatch);
} catch (MindsphereException e) {
    // Exception handling
}

Delete a File

Delete a file of an asset and from the specified path.

1
2
3
4
5
6
7
//Construct FileServiceClient object as shown above

try {
    fileServiceClient.deleteFile(entityId, filePath)
} catch (MindsphereException e) {
    // Exception handling
}

Search a File

Search one or multiple files of an asset in the specified path.

1
2
3
4
5
6
7
8
//Construct FileServiceClient object as shown above

List<File> fileSearchResponse;
try {
    fileSearchResponse = fileServiceClient.searchFiles(entityId, offset, limit, count, order, filter);
} catch (MindsphereException e) {
    // Exception handling
}

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.