RussCoder / djvujs

DjVu.js is a program library for working with .djvu files online without any connection with the server. DjVu.js Viewer is a widget that allows viewing .djvu files right in the browser and can be easily embedded into any web page.
https://djvu.js.org/
Other
184 stars 37 forks source link

Feature request: Use file name from Content-Disposition HTTP header if present #30

Closed r-pankevicius closed 4 years ago

r-pankevicius commented 4 years ago

Steps to reproduce in development environment, assuming you have built the project).

First set up environment to get djvu files with Content-Disposition headers. Copy viewer/craco.config.js from https://github.com/r-pankevicius/djvujs/commit/9a9a4221588d77eff1c2fb2b3bcfaddca0759f7d Now we have an devServer endpoint /djvufile?...arguments... to test different Content-Disposition headers.

To reproduce the issue:

  1. In viewer/src/index.js set initial url to this one: window.DjVuViewerInstance.loadDocumentByUrl("/djvufile?fname=%E5%9C%B0%E5%9B%BE.djvu&fntype=1");
  2. cd viewer
  3. npm start -> http://localhost:3000/ will open and display djvu file.

Issues:

  1. Viewer displays file name as djvufile?fname=%E5%9C%B0%E5%9B%BE.djvu&fntype=1 instead of nice file name 地图.djvu.
  2. When pressing save, no file name is present and browser suggests to save file "1" without extension (tried in Chrome). Would be nice to have 地图.djvu as file name to save.
RussCoder commented 4 years ago

I have implemented the similar functionality for the extension https://github.com/RussCoder/djvujs/blob/master/extension/background.js#L147

But not on the viewer side.

Also for now you have an option to load a file yourself and then feed the ArrayBuffer to the viewer with a filename. Although, you will not be able to see the loading progress.

You can try to add it yourself, it is loaded inside sagas. Or wait till the weekend or the next week.

r-pankevicius commented 4 years ago

I don't need to wait till the weekend because it works in my fork. If you'd like I can arrange a pull request for https://github.com/r-pankevicius/djvujs/commit/9a9a4221588d77eff1c2fb2b3bcfaddca0759f7d and https://github.com/r-pankevicius/djvujs/commit/8fd97578f4c02336096b1392aa33a790f4d37c9a solve the issue.