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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Creating a URL/Path to Custom Repository and files

khayes1
13-Aquamarine

Creating a URL/Path to Custom Repository and files

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.

5 REPLIES 5
mlähde
3-Visitor
(To:khayes1)

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

khayes1
13-Aquamarine
(To:mlähde)

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.

mlähde
3-Visitor
(To:khayes1)

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.

khayes1
13-Aquamarine
(To:mlähde)

Hi,

thanks again for your help. It does all seem to work now using LoadImage. It would b nice for future reference to be able to get the complete URL.

I just wondered if the reason your original suggestion didn't work is because there are no entities called '​FileRepositories​' as they are actually Things?

So should your original url  have been;

    /Thingworx/Things/<YourFileRepositoryThing>/<YourFile>

instead of:

/Thingworx/FileRepositories/<YourFileRepositoryThing>/<YourFile>


Kieron

mlähde
3-Visitor
(To:khayes1)

No, that should be the correct URL. You can evidence this by running the GetFileListingWithLinks service of your file repository thing.

snip.png

Top Tags