rejetto / hfs

HFS is a web file server to run on your computer. Share folders or even a single file thanks to the virtual file system.
GNU General Public License v3.0
2.29k stars 227 forks source link

Can't show text file #349

Closed dateno1 closed 1 year ago

dateno1 commented 1 year ago

BEFORE

To Reproduce Steps to reproduce the behavior:

  1. Open hfs with browser
  2. Try to show txt file
  3. Show white blank screen & txt is downloaded

Describe the bug I can't show txt file with show-any plugin

Image file is OK

Test.txt Sample file

Direct connect (without proxy) & by proxy (nginx) same result

It work well with chrome but firefox is not

Screenshots txt txt file (white blank) PNG png file (show image) ---------------------------------Upper is Firefox---------------------------------------------- Chrome Show txt with Chrome

Environment (please complete the following information): OS: Windows 10 x64 HFS Version : 0.48.0 Alpha.2~4 Browser : Firefox

Additional context

allowed_referer: "*.sample.com"
open_browser_at_start: false
log_gui: true
dont_log_net: 127.0.0.1|::1|192.168.0.0/16|10.0.0.0/8
proxies: 1
force_lang: en
enable_plugins:
  - antibrute
  - antidos
  - max-downloads-ip
  - mini-player
  - video-player
  - show-any
plugins_config:
  max-downloads-ip:
    limit: 10
  show-any:
    extensions:
      - ext: txt
      - ext: pdf
      - ext: flac
      - ext: mp3
      - ext: png
      - ext: jpg
      - ext: jpeg
      - ext: m4a
      - ext: ogg
      - ext: wav
      - ext: mp4
      - ext: mov
      - ext: wmv
      - ext: mkv
      - ext: webp
  antidos:
    max: 2000
admin_net: 127.0.0.1|::1|192.168.0.0/16|10.0.0.0/8
localhost_admin: false
vfs:
  source: root
base_url: https://file.sample.com
favicon: Favicon.ico
mime:
  "*.aac": audio/mp4
  "*.ape": audio/monkey
  "*.flac": audio/FreeLossless
  "*.m4a": audio/mp4
  "*.mid|*.midi": audio/midi
  "*.mp2|*.mp3": audio/mpeg
  "*.ogg|*.oga": audio/ogg
  "*.wav": audio/wav
  "*.weba": audio/webm
  "*.wma": audio/x-ms-wma
  "*.avi": video/x-msvideo
  "*.flv": video/x-flv
  "*.mp4": video/mp4
  "*.mkv": video/x-matroska
  "*.mpg|*.mpeg": video/mpeg
  "*.ogv": video/ogg
  "*.webm": video/webm
  "*.wmv": video/x-ms-wmv
  "*.gif": image/gif
  "*.ico": image/x-icon
  "*.jpg|*.jpeg": image/jpeg
  "*.png": image/png
  "*.svg": image/svg+xml
  "*.tif|*.tiff": image/tiff
  "*.webp": image/webp
  "*.css": text/css
  "*.csv": text/csv
  "*.js": text/javascript
  "*.txt": text/textfile
  "*.pdf": application/pdf
  "*": Auto
zip_calculate_size_for_seconds: 100

Current config

MIME for txt is not effected (with&without mime same result)

rejetto commented 1 year ago

you did very well at publishing your config! it's not a bug, your configuration is wrong. You set wrong mime type for txt files, "text/textfile" doesn't exist, and thus firefox doesn't recognize it. The correct one is "text/plain". But you are wasting your time at setting all those mime types, because the "auto" is already doing the same job for (probably) all the files you set. Your best solution is that you DELETE the row with *.txt, and the "auto" will do the right job. My suggestion is that you only configure the files when you are experiencing problems, otherwise you are causing problems instead of solving them.

dateno1 commented 1 year ago

you did very well at publishing your config! it's not a bug, your configuration is wrong. You set wrong mime type for txt files, "text/textfile" doesn't exist, and thus firefox doesn't recognize it. The correct one is "text/plain". But you are wasting your time at setting all those mime types, because the "auto" is already doing the same job for (probably) all the files you set. Your best solution is that you DELETE the row with *.txt, and the "auto" will do the right job. My suggestion is that you only configure the files when you are experiencing problems, otherwise you are causing problems instead of solving them.

Thanks for help

It fixed

But It not work with no MIME :(