4 Replies Latest reply on Nov 17, 2017 9:33 AM by khayes RSS
    khayes Explorer

    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.

      • Re: Creating a URL/Path to Custom Repository and files
        mlähde Explorer

        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

          • Re: Creating a URL/Path to Custom Repository and files
            khayes Explorer

            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.

              • Re: Creating a URL/Path to Custom Repository and files
                mlähde Explorer

                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.

                  • Re: Creating a URL/Path to Custom Repository and files
                    khayes Explorer

                    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