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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Imagelink and places to store images in ThingWorx

ptc-6291975
1-Newbie

Imagelink and places to store images in ThingWorx

Hi,

 

I have an application scenario whereby I wish to store images that I transferred from remote machines connected using ThingWorx. After the file transfer operation, I would like to store them locally in server machine hosting ThingWorx server.

 

My Question as below:

1. Is there any recommended places (if any) that Thingworx recommend to store the image files that received from machines? For example, under ThingworxStorage/Repository? considering ease of backup and maintenance in production environment?

 

2. I will need an image widget to display the image stored and based on user selection on the grid item. I believe IMAGE URL/imagelink will be the way to go. But what is the proper format to be specified to retrieve the image in the local machine hosting ThingWorx (Windows Server 2008)?

 

I tried all below combination with no luck:

file:///C:/ThingworxStorage/repository/SystemRepository/Station01/abc.gif

file://localhost/c:/ThingworxStorage/repository/SystemRepository/Station01/abc.gif

file:///c|/ThingworxStorage/repository/SystemRepository/Station01/abc.gif

file://localhost/c|/ThingworxStorage/repository/SystemRepository/Station01/abc.gif

 

Please kindly advise. Thanks!



4 REPLIES 4
adam11
5-Regular Member
(To:ptc-6291975)

Hi Yew,

Given your use case, I recommend storing the images in a File Repository. File Repository's have a Service, GetFileListingWithLinks(), that can be used to retrieve a link to the image. Retrieval of the image is done through a Service call. For example,


http://localhost/Thingworx/FileRepositoryDownloader?download-repository=SystemRepository&download-path=%2Fimage.tiff


Thanks,

Adam



Hi Adam,

Thanks for the advise. I think that is a good idea to use the GetFileListingwithLinks.


As I need to log the entry record of every image transferred from machine to ThingWorx, and apply filter to limit the date range of records using DateTime picker, I think I will use the DataStream for this purpose.


My further question is, how do I extract the LINK from GetFileListingwithLinks() -- Assume a single record returned using namemask, and copy that link and insert it to the DataStream record (together with other field defined in the datastream's datashape)? Any sample snippet for reference in this case?


Thanks.




adam11
5-Regular Member
(To:ptc-6291975)

After the file transfer is complete, you can retrieve the link and add a Stream entry using the following:

var image = Things["SystemRepository"].GetFileListingWithLinks().downloadLink;


var values = me.CreateValues();

values.name = nameMask;

values.url = image;


Things["ImageStream"].AddStreamEntry({

values: values,

source: principal

});


Of course, this method assumes a single record is returned by GetFileListingWithLinks().



Perfect! It works well. Thank you so much Adam.

Top Tags