Skip to main content
1-Visitor
November 9, 2017
Question

Creating a URL/Path to Custom Repository and files

  • November 9, 2017
  • 1 reply
  • 6963 views

Hi,

I am creating custom file repositories for each of my customers. The aim being to allow them to upload an image file to use in some mashups. The problem I have is in being able to create an image link to those files. How can I create URL for my custom repository and the files?

Thanks in advance.

1 reply

1-Visitor
November 9, 2017

Maybe store the URL in customer thing with a property that has base type HYPERLINK. The value of this property should be something like this: /Thingworx/FileRepositories/<YourFileRepositoryThing>/<YourFile> Then in a mashup use the GetProperties service of this thing and bind this property to the SourceURL property of the Image widget.

How to get the URL then... The File Upload widget has the event UploadComplete and the properties RepositoryName and FullPath that you can use as outputs. When the UploadComplete event fires you could pass these properties to a service of your own that constructs the URL and sets it as the value of aforementioned HYPERLINK property.

You might of course want to check that the uploaded file was indeed an image, but I’m not sure how to do that. File repositories seem to have a service called LoadImage, maybe load the uploaded file in memory with it and do some MIME type check.

Here's another thread that might be of use to you: Re: Loading image file in thingworx repository to image widget in mashup

khayes11-VisitorAuthor
1-Visitor
November 10, 2017

Hi,

thanks for the reply. I tried the URL you suggested, but couldn't get the correct path to the repository. I used the REST API to get to the entity listing but couldn't see any file repositories?

Decided to go with your suggestion of using LoadImage and a value display widget which seems to works for me. Thank you.

1-Visitor
November 17, 2017

As for the entity listing, the file repository thing resides under things because it implements FileRepository thing template which in turn implements GenericThing.


/Thingworx/FileRepositories/<YourFileRepositoryThing>/<YourFile> is the URL for the actual file saved in the file repository. So this is what you should use as the property value, if you were to go with my original suggestion. I'm glad you made it work anyhow.