Generate a Public URL

Prev Next

Generate a public URL to a media holder


When viewing an asset, there is an opportunity to generate a public URL to a media file.

  • It is necessary to have a defined site URL: System configuration > Site settings > Edit site > URL.

  • Users for whom public file sharing is allowed (in Media Holder Settings) have access to the "Copy Public Link" option.

By using this option, users are:

  • able to copy a public URL against active records;

  • able to copy a public URL against the latest version;

  • not able to copy a public URL against the previous version;

  • not able to copy a public URL against inactive records;

  • not able to copy a public URL against expired records;

Note: "Copy Public Link" option can be applied only for original media holders.

There are a few ways to copy a public URL per media holder:

  1. From the files panel in the item info sheet

  2. Using the API with the following endpoints (GET - to receive an already generated link, POST - to generate a link):

    • Internal API: /rest/site/{siteId}/module/{moduleId}/item/{itemId}/holder/{holderId}/getRedirectLinkToCurrentFileVersion

    • Expernal API: /rest/external/site/{siteId}/module/{moduleId}/item/{itemId}/holder/{holderId}/getRedirectLinkToCurrentFileVersion

    Note: The "API User" right need to be enabled for the user in order to have access to the API.

  3. Sending public redirect URL from single and multiple file fields in actions as a link:

#set($singleFileOption = $CurrentItem.findFirstFileInMediaHolder(1932))
#set($singleFileFieldThumbnail = $CurrentItem.findFirstFileInMediaHolder(1935))
#set($multipleFileOption = $CurrentItem.findFirstFileInMediaHolder(1936))
#set($multipleFileOptionThumbnail = $multipleFileOption.findFirstFileInMediaHolder(1937))
#set($multipleFileOptions = $CurrentItem.findFilesInMediaHolder(1936))
{
"itemId": "$CurrentItem.getId()",
"singleFileField" : {
"fileName": "$singleFileOption",
"publicRedirectUrl": "$singleFileOption.toPublicRedirectLink()"
},
"thumbnailSingleFileField" : {
"fileName": "$singleFileFieldThumbnail",
"publicRedirectUrl": "$singleFileFieldThumbnail.toPublicRedirectLink()"
},
"multipleFileFieldFirst": {
"fileName": "$multipleFileOption",
"publicRedirectUrl": "$multipleFileOption.toPublicRedirectLink()"
},
"thumbnailMultipleFileFieldFirst" : {
"fileName": "$multipleFileOptionThumbnail",
"publicRedirectUrl": "$multipleFileOptionThumbnail.toPublicRedirectLink()"
},
"multipleFileFieldAll": [
#foreach($currentMultipleFileOption in $multipleFileOptions)
{
"fileName": "$currentMultipleFileOption",
"publicRedirectUrl": "$currentMultipleFileOption.toPublicRedirectLink()"
}
#if($foreach.hasNext),#end
#end
]
}

Note: Only actions using Velocity Template Engine are currently supported (Send Email, HTTP).

List of generated public links is stored here: Home > Configuration > Metrics > Public Links

73cad2aff4.jpg


The expiration period of copied links is 6 months from the moment of link generation. Link generates each time a CREATE (POST) request is executed.

Additional information (scenario - current behaviour):

  • User creates a link to the same file again - a new link is created; the old link remains the same;

  • New file is uploaded, or version changed - the redirect URL link points to the latest version;

  • Link points to expired item - following links will return "401 Unauthorised";

  • Link points to inactivated item - following links will return "404 Not Found";

  • Site URL is empty - Public Links table is not available, message “Site URL is not configured, public links are not available” is shown;

  • Site URL is changed - previously generated links will work with a new Site URL (they need to be re-fetched or the Site URL manually replaced);

  • External API is disabled for the system (in the system properties file) - following links will return "404 Not Found".

Note: The Copy Public Link may function correctly for Custom Media Holders that have been used as destination folders for multiple sources in converters. This configuration is not supported.

Upload and store files in Google Cloud Storage (GCS)

Google Cloud Storage(GCS) is controlled by 2 feature flags in webapp.yaml:

encode.webapp.file-storage.default-type

encode.webapp.file-storage.google.enabled

encode:  
  webapp:
    file-storage:
      default-type: GOOGLE
      google:
        enabled: true   

Known limitations:

  • Single File field is not supported for uploading files to GCS

  • Pausing/resuming file uploads to GCS is not supported

Deletion of Files in GCS

Files uploaded to Universal file fields and stored in GCS are not deleted immediately from their storage, as happens to files stored in the local file structure.

When a file is deleted via the UI, or an item with an uploaded file is deleted, the file stored in GCS (file entity) gets an expiration date that schedules it for deletion. The file will be deleted within the standard clean-up process that takes place every 1 hour.

For public links, redirection to the file will work until the expiration settings of GCS (default is 6 hours), even though the file may be deleted by then.