Returning Responder

Change file name / display name when a new file is selected for a media object

Dear FirstSpirit community,

I have the requirement to adjust the URL of a media when the content of the media was changed. (See "Select new file")


The customer wants to change / update an existing file because of the following UseCases:

  • The file type changes e.g. "abc.docx" becomes "abc.pdf"
  • A newer version of a file is available e.g "abc.pdf" becomes "abc_v2.pdf"

Existing usages of the file on pages, sections and in datasets should not be changed! So only new file content should be uploaded.

The URL of the file should change so that a changed file type or a new version is reflected in the URL. (Important since we talk about download files where a new version like "_v2" should be visible in the download URL / file name for the user who downloads the document!)

Solution Idea

Using a StoreListener or / and an UploadHook to reset the stored URLs of the changed file and to set a new file name / display name when new file content was uploaded for an existing media object.

With this approach I can reset the stored URLs, that's no problem. So changed in the file extension like "abc.docx" to "abc.pdf" will take effect.

Problem / Question

When using a StoreListener and / or UploadHook there seems to be no way to get the file name of the file selected / uploaded by the user. So I cannot set the new file name / display name automatically. 

An UploadHook only provides the already existing Media object on which the old file name / display name is stored and an input stream from which the file name of the selected file cannot be extracted.
A StoreListener provides even less information by only providing the changed store element.

Is there a way to get the file name of the original file the user selected in the file upload dialog for SiteArchitect and ContentCreator?


Im happy for all ideas.


0 Kudos
0 Replies