MystenLabs / walrus-sites

Walrus Sites: Decentralized Websites using Sui and Walrus.
https://docs.walrus.site/walrus-sites/intro.html
Apache License 2.0
17 stars 16 forks source link

With the `--list-directory` option add `download` attribute to appropriate links #111

Open mlegner opened 2 months ago

mlegner commented 2 months ago

The --list-directory option added in #106 is convenient to build a file-browser like website from any directory. However, the links it creates are all direct links, which means the browser attempts to display the files.

This makes sense for some file types (text, images, maybe PDFs) but not for others (binary files). At least for the second category, it would be good to specify the link as <a href="..." download>...</a>. The easiest solution would be to just add it to all the links.

Unfortunately, this doesn't seem to work with the current portal: It simply downloads a 404.html page in my case, so this seems to be a separate issue.

mlegner commented 1 month ago

Maybe a better solution would be a Content-Disposition header.

But the download problem also occurs when "manually" downloading a file by right-clicking the link and selecting "Download linked file", so it would be good to solve this anyway.

giac-mysten commented 1 month ago

One solution could be to use js instead of plain links, so that the request has to go through the service worker... will think about this.