OpenWaterFoundation / owf-app-infomapper-ng

Open Water Foundation InfoMapper web application for menu-driven maps and visualizations, using Angular
GNU General Public License v3.0
1 stars 2 forks source link

Figure out how to provide links to assets for direct view/save #299

Open smalers opened 4 years ago

smalers commented 4 years ago

It would be useful to know how to create markdown/html links to the assets. For example, a simple way to let people download data files would be to manually create a table listing files or create with a script or command file. Need guidance on how to do this so that I can evaluate whether to explain this as an option for save/download of data files. Technical issues include:

  1. Can the table be included in popup info similar to how an image is included? What are the URLs in this case? The asset file would open in a new tab consistent with other link functionality, right?
  2. If a separate HTML file is used (new tab), what URLs are used to access files in the assets folder? This would be used if someone opened an asset file directly in a browser, or used an application like TSTool with WebGet command to download the asset file.

I'm not sure what variation makes sense. I'm just trying to figure out.

Nightsphere commented 4 years ago

The following Markdown syntax will not directly download a file when clicked, but will show the file in another tab with the complete file path as the URL. It also gives the user an option to right click on the link and choose Save link as... where the save as window will open and give them an option to name the file whatever they like.

[Download with Markdown link](assets/app/data-maps/map-layers/active-ditches.geojson)

The HTML below will let a user directly download the file when left clicked, and right click offers the same options from above. an optional attribute value is filename where something like filename="filename.txt" would specify the name of the downloaded file.

<a href="assets/app/data-maps/map-layers/active-ditches.geojson" download>Download with HTML link</a>

Some file extensions are downloaded automatically when given as a URL to a browser, and some are displayed. There is a good Medium article about it here:

https://medium.com/@gaurav5430/web-security-forcing-browsers-to-download-a-file-instead-of-previewing-it-a86aede05dc7.

It looks like there are a couple headers that can be set/changed to force a browser to download or display, depending on what we want it to do. I don't think this is extremely necessary right now, but it might be good to know in the future.