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!
Insights Hub drives smart manufacturing through the industrial Internet of Things. Gain actionable insights with asset and operational data and improve your processes.
The IoT File Services Service 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-python-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 angular brackets < >.
# Import the RestClientConfig and UserToken from mindsphere_core modulefrommindsphere_coreimportRestClientConfigfrommindsphere_coreimportUserToken# Import the MindsphereError from mindsphere_core.exceptions modulefrommindsphere_core.exceptionsimportMindsphereError# Import the FileServiceClient from iotfile modulefromiotfileservicesimportFileServiceClient# Import all required models from iotfile.modelsfromiotfileservicesimport*# Create the RestClientConfig and UserToken objectsconfig=RestClientConfig(proxy_host="<proxy_host>",proxy_port=<proxy_port>)credentials=UserToken(authorization="<bearer_token>")# Create the FileServiceClient object using the RestClientConfig and UserToken objectsfiles_client=FileServiceClient(rest_client_config=config,mindsphere_credentials=credentials)try:# Create the request objectrequest=PutFileRequest(file="<file>",if_match="<if_match>",filepath="<filepath>",description="<description>",entity_id="<entity_id>",type="<file type>",timestamp="<timestamp>")# Initiate the API call to write a fileresponse=files_client.put_file(request)exceptMindsphereErroraserr:# Exception Handling
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=GetFileRequest(filepath="<filepath>",entity_id="<entity_id>")# Initiate the API call to read a fileresponse=files_client.get_file(request)exceptMindsphereErroraserr:# Exception Handling
Delete a file of an asset and from the specified path.
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=DeleteFileRequest(filepath="<filepath>",entity_id="<entity_id>")# Initiate the API call to delete a fileresponse=files_client.delete_file(request)exceptMindsphereErroraserr:# Exception Handling
Search one or multiple files of an asset in the specified path.
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=SearchFilesRequest(filter="<filter>",offset=<offset>,limit=<limit>,count=<count>,entity_id="<entity_id>",order="<order>",)# Initiate the API call to search a fileresponse=files_client.search_files(request)exceptMindsphereErroraserr:# Exception Handling
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=GetFileListRequest(filepath="<filepath>",entity_id="<entity_id>")# Initiate the API call to list filesresponse=files_client.get_file_list(request)exceptMindsphereErroraserr:# Exception Handling
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=PutFileRequest(entity_id="<entity_id>",filepath="<filepath>")# Initiate the API call to start a multi part uploadresponse=files_client.initiate_multi_part_upload(request)exceptMindsphereErroraserr:# Exception Handling
Upload parts of an initiated multi part upload with the provided content in the specified path.
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=PutFileRequest(file="<file>",entity_id="<entity_id>",filepath="<filepath>",description="<description>",timestamp="<timestamp>",type="<file_type>",part=<part_number>)# Initiate the API call for part uploadresponse=files_client.create_multi_part_file(request)exceptMindsphereErroraserr:# Exception Handling
Complete a multi part upload using the PutFileRequest model.
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=PutFileRequest(entity_id="<entity_id>",filepath="<filepath>")# Initiate the API call to complete a multi part uploadresponse=files_client.complete_multi_part_upload(request)exceptMindsphereErroraserr:# Exception Handling
Abort a multi part upload using the PutFileRequest model.
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=PutFileRequest(entity_id="<entity_id>",filepath="<filepath>")# Initiate the API call to abort a multi part uploadresponse=files_client.abort_multi_part_upload(request)exceptMindsphereErroraserr:# Exception Handling
Initiate the Update of an Existing Multi Part Upload¶
To update an existing multi part upload, it is required to re-initiate the multi part upload for an asset in the specified path. Note that the ifMatch parameter is mandatory for this action.
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=PutFileRequest(entity_id="<entity_id>",filepath="<filepath>",if_match="<if_match>")# Initiate the API call to start an update of a multi part uploadresponse=files_client.initiate_multi_part_upload(request)exceptMindsphereErroraserr:# Exception Handling
Update a part an existing multi part upload with the provided content in the specified path using the PutFileRequest model. Note that the ifMatch parameter is mandatory for this action.
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=PutFileRequest(file="<file>",entity_id="<entity_id>",filepath="<filepath>",description="<description>",timestamp="<timestamp>",type="<file_type>",part=<part_number>,if_match="<if_match>)# Initiate the API call to update an uploaded partresponse=files_client.update_multi_part_file(request)exceptMindsphereErroraserr:# Exception Handling
Complete the Update of an Existing Multi Part Upload¶
Complete the update of an existing multi part upload using the PutFileRequest model. Note that the ifMatch parameter is mandatory for this action.
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=PutFileRequest(entity_id="<entity_id>",filepath="<filepath>",if_match="<if_match>")# Initiate the API call to complete the update of a multi part uploadresponse=files_client.complete_multi_part_upload(request)exceptMindsphereErroraserr:# Exception Handling
Abort the Update of an Existing Multi Part Upload¶
Abort the update of an existing multi part file upload using the PutFileRequest model. Note that the ifMatch parameter is mandatory for this action.
# Create the FileServiceClient object as shown abovetry:# Create the request objectrequest=PutFileRequest(entity_id="<entity_id>",filepath="<filepath>",if_match="<if_match>")# Initiate the API call to abort the update of a multi part uploadresponse=files_client.abort_multi_part_upload(request)exceptMindsphereErroraserr:# Exception Handling