Skip to main content
Sep 23, 2022 10:22 AM UTC
Solved

Image file to IMAGE basetype

Started developing extension to get image file from windows file explorer. 

 

  • Created resource
  • Created service [input: imagePath, output: IMAGE]

Here how to convert Imge file to thingworx IMAGE basetype?

Sep 25, 2022 2:53 AM UTC

Got solution with by converting image file into Base64 String.

String base64String = null;
File imageFile = new File(imagePath);
byte[] fileContent = FileUtils.readFileToByteArray(imageFile);
String encodedString = Base64.getEncoder().encodeToString(fileContent);
base64String = encodedString;

2 replies

Sep 24, 2022 5:19 AM UTC

Hi,

 

Following link may be helpfull

How-to-load-the-image-into-thingworx-storage-media-dynamically 

 

 

Hope this helps!!

Sathishkumar_CAuthorAnswer
Sep 25, 2022 2:53 AM UTC

Got solution with by converting image file into Base64 String.

String base64String = null;
File imageFile = new File(imagePath);
byte[] fileContent = FileUtils.readFileToByteArray(imageFile);
String encodedString = Base64.getEncoder().encodeToString(fileContent);
base64String = encodedString;