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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to load the image into thingworx storage media dynamically

vi1
15-Moonstone
15-Moonstone

How to load the image into thingworx storage media dynamically

Hi,

 

Could you give the example for how to load the image dynamically.

Example: user has to load the image from local system at run time(C: drive ).

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
cbuse
12-Amethyst
(To:vi1)

Hi,

 

The widget fileupload allows the user to select a file from the file system and upload it in a ThingWorx FileRepository. 

From the file repository, the image can be saved as a media entity.

 

// load the image from ThingWorx file repository
var paramsLoadImage = {
  path: imagePath /* STRING */
};
var imageContent = Things[repositoryName].LoadImage(paramsLoadImage);

// create a media entity
var paramsCreateMediaEntity = {
  name: imageName /* STRING */,
  content: imageContent /* IMAGE */
};
Resources["EntityServices"].CreateMediaEntity(paramsCreateMediaEntity);

// output the source URL of the media entity which can be used as input for the image widget
var result = "/Thingworx/MediaEntities/" + imageName

View solution in original post

2 REPLIES 2
cbuse
12-Amethyst
(To:vi1)

Hi,

 

The widget fileupload allows the user to select a file from the file system and upload it in a ThingWorx FileRepository. 

From the file repository, the image can be saved as a media entity.

 

// load the image from ThingWorx file repository
var paramsLoadImage = {
  path: imagePath /* STRING */
};
var imageContent = Things[repositoryName].LoadImage(paramsLoadImage);

// create a media entity
var paramsCreateMediaEntity = {
  name: imageName /* STRING */,
  content: imageContent /* IMAGE */
};
Resources["EntityServices"].CreateMediaEntity(paramsCreateMediaEntity);

// output the source URL of the media entity which can be used as input for the image widget
var result = "/Thingworx/MediaEntities/" + imageName

vi1
15-Moonstone
15-Moonstone
(To:cbuse)

Thank You for solution. Its working for me

Top Tags