Skip to main content
17-Peridot
September 23, 2022
Solved

Image file to IMAGE basetype

  • September 23, 2022
  • 2 replies
  • 1213 views

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?

Best answer by Sathishkumar_C

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

15-Moonstone
September 24, 2022

Hi,

 

Following link may be helpfull

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

 

 

Hope this helps!!

Sathishkumar_C17-PeridotAuthorAnswer
17-Peridot
September 25, 2022

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;