Media Entity Service Methods
The following services can be used to construct the URL for retrieving dynamic content for
media entities.
String GetProxyUrl(String targetUrl, [Boolean isAbsoluteUrl] )
At run time, the media entity combines the configured base URL and the url parameter to create the full target URL. For example:
http://my.thingworx.server:8080/Thingworx/MediaEntities/
MyProxy/Content/...trailing part of real url
|
To ensure that the URLs are properly formed and encoded for use in mashups, use the GetProxyUrl service method.
|
|
For single sign-on (SSO) authentication, enter a URL that supports OAuth.
|
Parameters
• targetUrl
The URL to content on the origin server. This must be reachable from the ThingWorx server.
|
If the content on the origin server is reachable from the client browser, you do not need to use a media entity. Instead, you can use the URL directly in a Image Widget or Link Widget.
|
• isAbsoluteUrl
This parameter is optional.
◦ true
Set this parameter to true if the target URL is a full, absolute URL to the origin server. The targetUrl must start with the configured base URL.
◦ false
Set this parameter to false if the target URL is relative to the configured base URL. The targetUrl is appended to the base URL to determine the actual target URL.
If this parameter is not provided, the default value is false (relative). Relative URLs are convenient to use from mashups since the configured base URL of the media entity can be unknown.
• twxME_ClientFollowRedirect
This parameter is false by default. When true, the provided redirect URL is followed.
Examples
These examples assume that the content is not reachable by the end-user's browser. If the URLs are reachable by the browser, use them in your mashup; there is no need to proxy the content through a media entity.
• These examples use a new media entity called MyProxy.
• The URL on the ThingWorx server where the content will be made available is Content URL.
• The examples assume the ThingWorx server is on thingworx.my and the actual content is on content.acme.com.
A Single Simple URL
• Target URL: http://content.acme.com/images/example.jpg
This is what you are trying to surface.
• MyProxy.URL: http://content.acme.com/images/example.jpg
• Content URL: http://thingworx.my/MediaEntities/MyProxy/Content
This is the URL where ThingWorx will proxy the actual content.
Multiple Content URLs
Typically, a single origin server will serve content from many related URLs. Rather than setting up a media entity for each URL, you can use a single media entity to proxy many related origin URLs.
• Target URLs: http://content.acme.com/images/[image1.jpg, image2.jpg, image3.jpg. …]
• MyProxy.URL: http://content.acme.com/images/
• Content URLs:
◦ http://thingworx.my/MediaEnties/MyProxy/Content/image1.jpg
◦ http://thingworx.my/MediaEnties/MyProxy/Content/image2.jpg
◦ http://thingworx.my/MediaEnties/MyProxy/Content/image3.jpg
◦ http://thingworx.my/MediaEnties/MyProxy/Content/...
In this case, the media entity concatenates the base URL and url parameter and uses that for the actual target URL from which to proxy content.