Dynamic asset search and empty folders

Hi,
I am using playlists with different characteristics based on a Dynamic asset search with assets read from a folder. This works very good as soon as you do not remove all assets from a folder. In this case the folder is automatically deleted, which makes it impossible to simply use the folder again. As I plan to make the configuration available for some people with poor IT knowledge, I would like to give them a very simple guide like for standard images put them in the 5sec-folder, for special events put them in the 15sec-folder etc.
But as (e.g.= the 15sec-folder disappears, when they remove the last image from the folder, they would need to reconfigure a couple of things, when they need the folder again.
Do you know if there is a workaround so that the folder is not deleted, when empty?
Thanks
Best regards
Alexander

Indeed. Let me explain and offer a (temporary?) solution: This might not be obvious from the UI but info-beamer’s backend has no concept of folders. Instead every asset you upload has a filename. Such a filename can include one or more slash / characters. If so, the asset page, by convention, uses those to generate a virtual folder tree.

If you, for example, upload an asset with filename images/image1.jpg, the asset page shows a folder images containing the file image1.jpg. If you remove the last asset having the prefix images/ in its filename, the virtual folder ceases to virtually exist.

There is now a (temporary?) workaround to force empty folders: You can upload a JSON file named asset-config.json to your account. It must look like this:

{
  "forced_directories": [
    "photos",
    "a/b/c/d/e/f/g/h"
  ]
}

Each entry in the forced_directories list is a folder displayed in the UI despite it being potentially empty. That way you (or your users) can select the folder and upload file into it, which as describe above, only means that the uploaded file gets the folder name as its filename prefix.

All this is really a purely browser-side workaround around the asset API design. A more sensible solution might be for the backend to understand the intention of / within filenames and do its own lifetime tracking of folders and the ability to then either keep or delete orphaned folders.

Feedback welcome.

Hi Florian,
Thanks for your fast reply
I created now the json file with my small directory structure and uploaded it simply as a usual asset and now the directories are displayed now permanently (even the empty ones). It is perhaps not very intuitive, but it is exactly what I wanted. Thank you so much again.
Have a nice day
Alexander

Agreed. Thinking aloud here:

  • The current method clearly has a discovery problem: Unless you know it exists or happen to find (for now) this post, you’ll never know the feature exists. Clearly not good.

  • There is also no UI. While the /asset/upload API prevents you from uploading syntactically wrong JSON files, it doesn’t prevent you from uploading semantically incorrect ones. So you don’t get any feedback on whether or not the asset-config.json works other that looking at the result.

  • This might be handled as a purely browser-side problem. As said previously, the backend doesn’t really care if and how the slash character is used within an asset’s filename. The fact that files appear organized within folders is purely done within the browser rendering the dashboard pages. In that case the question is: Where do you keep the state the instructs that browser-side code to show empty folders.

    • The current solution is to use a specially named file as an API endpoint to easily retrieve its content already exists. The result is that the current implementation was like 20 lines of added/changed code.

    • An alternative might be to add to add a field within the account’s userdata value as this might be considered an account-wide setting and userdata values are intended to store state intended to be used by the API caller. Although it still feels like that’s not 100% fitting as it then commingles data used by the info-beamer dashboard with potential data intended for user managed API clients.

    • A final and also fairly easy to implement method would be to store the state of “deleted folders” within the browser itself in its localStorage: If you delete the last assets from a “folder”, the asset list would realize that and store the orphaned folder name. Any followup reload of the asset page would then use that to show the empty folder. This would make all the handling automatic as you wouldn’t have to manually configure folders, but would mean that the state is lost if you log in with another browser or from another machine. This might be confusing.

    • The third method might also use either the asset file method or the userdata method instead of localStorage to store state. So the “automatic” property might be implemented for the other two as well.

  • Another option would be to implement a set of folder API calls intended to allow handling of folders directly. This would then also help with implementing folder renames properly: Right now if you want to rename a “folder”, you have to instead rename each individual asset within that “folder”. Similarly if you want to delete everything within a “folder”, you’ll instead have to remove all assets within it.

    • Doing that isn’t trivial as it adds another abstraction to the way assets are handled. Also info-beamer tries hard to have all API calls to be as fast as possible, so all calls must be implemented in a way that still works well for accounts with tons of files or tons of directories. It feels doable, but I didn’t invest any thought in that so far.

    • It adds quite a bit of complexity for a seemingly small feature. So not sure that’s worth it.

  • My conclusion at the moment: Let’s keep it as it is and see how often this issue pops up.