Themelia Pro A powerful new development platform built on ASP.NET.
 
Using File Aliases
 
 

One type of endpoint that Themelia Pro provides is called a file alias.  This type of alias is actually rather similar to the concept of symbolic links in Unix-style operating systems.  The basic idea is that there may be one or more logical paths for the same physical resource.  This decoupling of your logical and physical world's allows you to rename a physical file without the rest of the world seeing broken link.

One example of how a file alias could be used can be seen in the major products around the world.  Say there was a major JavaScript framework in the world that publicly releases its single-file framework as ProductName.VersionNumber.js as in my-framework.1.0.4.js.  What happens when this framework becomes my-framework.1.0.5.js?  Now you have to chase your links all over the place to upload them to the new path (and hope the caching catches up sooner rather than later).  Fortunately, this isn't what these guys typically do.  Instead, the people who deploy the framework create an alias called my-framework.latest.js which points to the real file.  Now when the version changes, they only change the connection to that file in some type of internal resource (or in the case of Unix/Linux, change the symbolic link).  They don't have to ever touch the physical endpoint shown to the world.

Themelia Pro provides this capability via a file alias.  You can implement a file alias in two ways: via endpoint parameters and inline in an endpoint.

Via Endpoint Parameters

Endpoint parameters are parameters used to send extra informationt to the backing type of an endpoint.  In this case, the parameters are used to tell configure the file system with the target file name and, optionally, the content-type.  If no content-type is set, then no content-type is sent along with the file.

Endpoint parameters are installed as in the following example:

<themelia.web>
  <webDomains>
    <add>
      <endpoints>
        <add selector="endsWith" text="/download/my-framework.latest.js" type="FileAlias">
          <parameters>
            <add name="target" value="/Resource_/Release/my-framework.1.0.4.js" />
            <add name="contentType" value="text/javascript" />
          </parameters>
        </add>
      </endpoints>
    </add>
  </webDomains>
</themelia.web>

 Inline in the Endpoint

The other way to configure a file alias is inline in the endpoint using the "parameter" attribute.  Just put either your target in the parameter or both the content-type and target in the parameter, separated by a colon.

<themelia.web>
  <webDomains>
    <add>
      <endpoints>
        <add selector="endsWith" text="/download/my-framework.latest.js" type="FileAlias" parameter="text/javascript:/Resource_/Release/my-framework.1.0.4.js" />
      </endpoints>
    </add>
  </webDomains>
</themelia.web>

Content Type

The content-type can be content-type, but it needs to make sense for what you are doing.  For example, if you make an alias for a zip file, make sure you are sending the file as using application/zip.  When you want to alias a new type of file, be sure to do a quick Google search to see what the appropriate content type is for that particular file type.  One resource to get you started is http://www.webmaster-toolkit.com/mime-types.shtml.  This is a list of content types and how they map to common file extensions.

Loose Coupling

Like with pages and services, one extremely important point about aliases relates to coupling.  If you have a publicly accessible resource whose logical path matches its physical path, you may find yourself in big trouble in the future.  The moment your physical resource moves or is renamed, all links, local and remote, must be changed.  Therefore, if you are versioning public files, perhaps you should think about using an alias from the start.