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:
Please kindly advise. Thanks!
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,
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?
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;
Of course, this method assumes a single record is returned by GetFileListingWithLinks().