There are a number of ways to embed asset files — including thumbnails, previews, views or the original itself — in remote web site pages. This article describes a simple way to do this by combining the security access via Sharing Assets ("Tokens") and File Retrieval API file calls. Please see related articles on this underlying functions if you are not already familiar with them:
Designate an embed folder
In this example, the management opening access to NetX such that assets can be embeddable will be accomplished by creating a special "Embed" folder. It really doesn't matter what you call it, or where it's located in NetX. The idea is simply that when this project is completely setup, you can enable embedding for an asset simply by adding it to your "Embed" folder (it can live in many folders as aliases). This simply makes management of these embedded files easier if you create a single Token (more on this below) for a folder, and then add as many assets as you like into it.
Obtain a token
Once you have your "Embed" folder, you can create a share link to that folder. Start by navigating to the Tools menu, and choosing the "Links" option.
We strongly recommend that you create the share link using a "service" account that is maintained by your system administrators and not in use by a specific employee.
There, you can create a Shared Link:
Ensure you create it without an expiration (if that's what you want), and without any further security options.
Next, select the access options you want to provide. In this example, we'll select "Original", "Thumbnail", and "Preview":
When you save it, you'll receive a link URL, like this:
Copy that. Specifically, you'll need the string of characters that follows the "/request/" portion of the URL. In this example, the access token is:
That token allows for access to the underlying assets (in the "Embed" folder in this example"), and to the download options explicitly configured ("Original", "Thumbnail", and "Preview").
Craft file retrieval URL
Next, you can create a File Retrieval URL for your embed code. Please refer to the File Retrieval API for more details on the syntax of these URLs. But to illustrate this, you need the syntax, and an Asset ID. The Asset ID is available within the NetX UI on any Asset Detail page, and on the File Info tab.
Let's say you have Asset ID "678". So the File Retrieval URL to the original is:
And the URL to the thumbnail is:
However, to use these URLs you need to be authenticated with NetX. And you can't reasonable accomplish this for anonymous users on your remote Web site. That's where tokens can be used to effectively unlock these URL for anonymous users. Simply append the token onto the query string, like this:
And now: magic! The URL can be used in an unauthenticated context. Assuming this is an image asset, you can embed it into your HTML like this:
The same can be accomplished with thumbnails and preview ("proxy") derivatives of the asset (or even Asset View files).
Please note that you must specify any used options in your Shared Link configuration. That is, if you only check "Original", and then try and create a File Retrieval URL for a thumbnail, then you'll get an HTTP 401 ("forbidden") response.