The chat responses are generated using Generative AI technology for intuitive search and may not be entirely accurate. They are not intended as professional advice. For full details, including our use rights, privacy practices and potential export control restrictions, please refer to our Generative AI Service Terms of Use and Generative AI Service Privacy Information. As this is a test version, please let us know if something irritating comes up. Like you get recommended a chocolate fudge ice cream instead of an energy managing application. If that occurs, please use the feedback button in our contact form!
Skip to content
Insights Hub and Industrial IoT

Insights Hub drives smart manufacturing through the industrial Internet of Things. Gain actionable insights with asset and operational data and improve your processes.

IoT File Services Client for Node.js¶

Introduction¶

The IoT File Services Node.js client allows you to manage files related to assets. Refer to IoT File Service for more information about the service.

Further implementation of the IOT File Service SDK library has been shown in a sample project that you can download and test in local or on Insights Hub application. Please refer to this repository: industrial-iot-node-sdk-examples

Hint

In the IoT context, assets are referred to as entity and aspects as propertyset.
Placeholders in the following samples are indicated by angle brackets < >.

File Operations¶

Client name: FileServiceClient

Create or Update a File¶

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

// Import the mindsphere-sdk-node-core module and require AppCredentials and ClientConfig
let AppCredentials = require('mindsphere-sdk-node-core').AppCredentials;
let ClientConfig = require('mindsphere-sdk-node-core').ClientConfig;

// Import the iotfileservices module and require FileServiceClient
const FileServiceClient = require('iotfileservices-sdk').FileServiceClient;


// Construct the ClientConfig and AppCredentials objects
let config = new ClientConfig();
let credentials = new AppCredentials();

// Construct the FileServiceClient object
let file_service_client = new FileServiceClient(config, credentials);

try {
  const request_object = {
    file: <file>,
    entityId: <entity_id>,
    filepath: <file_path>,
    ifMatch: <ifMatch>,
    timestamp: <timestamp>,
    description: <description>,
    type: <type>
  };

  await file_service_client.putFile(request_object);
} catch (ex) {
  // Exception handling
}

Read a File¶

Read a file for an asset from the specified path.

// Construct the FileServiceClient object as shown above

let file_data;
try {
  const request_object = {
    entityId: <entity_id>,
    filepath: <file_path>,
    ifNoneMatch: <ifNoneMatch>
  };

  file_data = await file_service_client.getFile(request_object);
} catch (ex) {
    // Exception handling
}

Delete a File¶

Delete a file from an asset at the specified path.

// Construct the FileServiceClient object as shown above

try {
  await file_service_client.deleteFile({ entityId: <entity_id>, filepath: <file_path> });
} catch (ex) {
  // Exception handling
}

Search a File¶

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

// Construct the FileServiceClient object as shown above

let file_search_response;
try {
  const request_object = {
    entityId: <entity_id>,
    offset: <offset>,
    limit: <limit>,
    count: <count>,
    order: <order>,
    filter: <filter>
  };

  file_search_response = await file_service_client.searchFiles(request_object);
} catch (MindsphereException e) {
  // Exception handling
}