cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Create Image from binary file

Yoshihiko.N
14-Alexandrite

Create Image from binary file

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

 

 

ACCEPTED SOLUTION

Accepted Solutions

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

 

View solution in original post

3 REPLIES 3

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

 

 

 

Yoshihiko.N
14-Alexandrite
(To:Velkumar)

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

YoshihikoN_0-1696227226317.png

 

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

 

Announcements


Top Tags