Skip to main content
14-Alexandrite
October 2, 2023
Solved

Create Image from binary file

  • October 2, 2023
  • 1 reply
  • 3236 views

Hi Developers,

I'm trying to create the following functions.

1. save image file to SQL as binary data.
2. pull binary data from SQL.

3. create Image contents from the binary data to display on mashup.

 

I'm struggling to create codes for part 3.


Could anyone help me for the part3?

 

 

YoshihikoN_1-1696221863880.png

 

 

Best answer by Velkumar

Hi @Yoshihiko.N 

 

You are trying to convert base64/binary data again to base64 string

 

Output from LoadBinary can be directly viewed as an Image

let result = Things["SystemRepository"].LoadBinary({
	path: "/images.png" /* STRING */
});

 

Velkumar_2-1696228622467.png

 

In your use case :

// Image binary string
let data = Things["SystemRepository"].LoadBinary({
	path: "/images.png" /* STRING */
});

// Write service to store data in DB

// Query data from DB 
// For example : input dbString will be data from the DB
var result = dbString;

 

Velkumar_3-1696229301184.png

 

/VR

 

1 reply

19-Tanzanite
October 2, 2023

Hi @Yoshihiko.N 

 

Set the result output type to Image

Velkumar_0-1696224137845.png

More Information - 

Solved: Convert base64 code to image - PTC Community

 

/VR

 

 

 

14-Alexandrite
October 2, 2023

Hi 
Thank you for your quick response.
I tried but failed.

YoshihikoN_0-1696227226317.png

 

Velkumar19-TanzaniteAnswer
19-Tanzanite
October 2, 2023

Hi @Yoshihiko.N 

 

You are trying to convert base64/binary data again to base64 string

 

Output from LoadBinary can be directly viewed as an Image

let result = Things["SystemRepository"].LoadBinary({
	path: "/images.png" /* STRING */
});

 

Velkumar_2-1696228622467.png

 

In your use case :

// Image binary string
let data = Things["SystemRepository"].LoadBinary({
	path: "/images.png" /* STRING */
});

// Write service to store data in DB

// Query data from DB 
// For example : input dbString will be data from the DB
var result = dbString;

 

Velkumar_3-1696229301184.png

 

/VR