Skip to content

IoT File Client for Java

Introduction

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

See IoT File Service for more information about the service.

File Operations

Client name: FileservicesClient

Create a File

Create a file for the specified entity and path with the provided content.

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

FileWriterResponse fileWriterResponse;
try {
    fileWriterResponse = fileservicesClient.createFile(file,entityId,filepath,description,type);
} catch (MindsphereException e) {
    // Exception handling
}

Update a File

Update a file for the specified entity and path with the provided content.

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

FileWriterResponse fileWriterResponse;
try {
    fileWriterResponse = fileservicesClient.updateFile(file, entityId, filepath, description, type, ifMatch);
} catch (MindsphereException e) {
    // Exception handling
}

Read a File

Read a file for the specified entity and path. The GET method is used for the API call.

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

FileReaderResponse fileReaderResponse;
try {
    fileReaderResponse = fileservicesClient.readFile(entityId, filepath, ifNoneMatch)
} catch (MindsphereException e) {
    // Exception handling
}

Delete a File

Delete a file for the specified entity and path.

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

boolean isFileDeleted;
try {
    isFileDeleted = fileservicesClient.deleteFile(entityId, filepath)
} catch (MindsphereException e) {
    // Exception handling
}

Search a File

Search one or multiple files for the specified entity and path.

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

FileSearchResponse fileSearchResponse;
try {
    fileSearchResponse = fileservicesClient.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.