Preview of static asset in admin panel

83 Views Asked by At

How do I preview some static asset in the admin panel ? Is there any way to download it ? Field config in entity class is following:

   @Column(name = "ASSET_FILE")
   @AdminPresentation(friendlyName = "Asset_file", fieldType = SupportedFieldType.ASSET_LOOKUP,
           group = SomeClass.GroupName.IMAGE)
   private String assetFile;

User has the possibility to upload his profile file (not necessarily image), and as an admin I would like to be able to preview and download it (from the customer profile in admin panel).

fieldType = SupportedFieldType.ASSET_LOOKUP gives only the chance to upload file from the list or remove the current one.

View from the admin panel after uploading .pdf file: enter image description here

Any kind of help would be appreciated ;)

1

There are 1 best solutions below

1
On BEST ANSWER

This sounds like a good enhancement to make this automatic, perhaps open an issue at https://githbu.com/BroadleafCommerce/Issues?

As a workaround, when you view the file in the admin, it has a URL field. To actually load that URL, you can prefix the url with /cmssstatic for Broadleaf to resolve it.

For example, if you updload a file file.pdf then you should see in the admin that the URL is /file.pdf. To actually get to that file, go to https://localhost:8444/admin/cmsstatic/file.pdf in your browser.

You can also access this on the frontend with https://localhost:8443/cmsstatic/file.pdf.