Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide actual filename of downloaded files rather than e.g. download.jpg #3797

Closed
gabuzi opened this issue Sep 8, 2022 · 8 comments
Closed

Comments

@gabuzi
Copy link

gabuzi commented Sep 8, 2022

Feature request

Hi!

In our pipeline, we take care to name images uploaded to elabFTW in a meaningful way. The reverse process, e.g. downloading an image by dragging&dropping them from elabFTW into a local folder or through "save image as", will create files named like download.jpg. Likewise, clicking "save link as" on an attached PDF suggests to save the file as "download.pdf".

The behavior is reported for elabFTW 4.3.10, tested on Chromium 98.0.4694.0 and Firefox 104.0.1.

It would be quite convenient for consistency to have a straightforward way of downloading images with their originally stored name.

Thanks!

I'm using the hosted version or I have PRO support: NO

@NicolasCARPi
Copy link
Contributor

I've seen this too. For PDF, if you click the link on the name of the pdf, you'll see that the correct name appears on saving. But if you click the thumbnail, then the name is incorrect.

For images it seems both cases fail to provide the correct name for download. This can probably be fixed. I'm requalifying this issue as a bug report rather.

@NicolasCARPi
Copy link
Contributor

Ok I figured out the bug. The Content-Disposition header was only set when forceDownload was set (on pdf for instance), because it was needed to force the download. Now I also set it for other files that can be displayed in the browser but with inline disposition. And now the correct file name is shown upon saving!

@gabuzi
Copy link
Author

gabuzi commented Sep 8, 2022

Cool, thanks a lot! Looking forward to hypernext :)

NicolasCARPi added a commit that referenced this issue Sep 17, 2022
* hypernext:
  add users to apiv2 doc
  add query parameters in api doc for experiments and items GET
  add apidocv2 yarn command
  remove dead code, check is handled in readAll
  fix issue with incorrect semantic version compare
  fix event deletion notification preferences not honored
  fix filename download with non ascii characters
  correctly use the image name on download.php. fix #3797
  add more columns to csv scheduler export
  add bound entity title to event output and ui
  make full syntax link on search page appear like a link
  improve ui for ucp change pass
@gabuzi
Copy link
Author

gabuzi commented May 29, 2023

Hi!

Thanks for implementing and constantly improving the app!

It took a while for me to get back to this. The issue is resolved when opening an image from the attachments section and then right-click 'save image as...' in Firefox.

However, what I tend to do (which seems more natural to me) is to drag and drop images from the body of the displayed experiment to a folder on the mac or use the 'save as' method. Doing this now results in unnamed_file.<ext> being saved, so it seems like this issue has not been fully resolved!

We're still on 4.5.13, but judging from the changelog, it doesn't look like there was a recent change that would have changed this for 4.6.x.

@NicolasCARPi
Copy link
Contributor

I am not sure how the browser can pickup the filename on a drag out action or right click save as. Do you have an example web app that does that to provide?

@NicolasCARPi NicolasCARPi reopened this May 29, 2023
@gabuzi
Copy link
Author

gabuzi commented May 30, 2023

I tracked it down to a difference in how the href attributes is set. In the attachment section, where drag&drop works, there are additional get parameters like storage and name in addition to the f for download.php. These are missing in the main text of the experiment if you add an image there.

In my quick tests, simply appending &name=canbeanything will lead to the browser picking up that name, which then also be used for storing on the file system after drag&drop. In my tests on MacOS 13, I found that you can even leave the extension away or put a wrong one, and it will be set to the correct one after drag&drop (probably from the MIME type).

So in summary, it may be as simple as adding the proper &name= parameter to the href attributes for images displayed in the body.

@NicolasCARPi
Copy link
Contributor

Done!

@gabuzi
Copy link
Author

gabuzi commented Sep 9, 2023

Sorry, it took a while for me to update to recent versions. The following was tested with 4.8.3.

I've tested and the solution does work for images inserted via the attachments section below the editor and then selecting 'insert in text at cursor position'. However, if you drag&drop an image from the filesystem directly into the editor (not into the drag&drop area), the 'name' attribute is not set in the html and the file shows as 'unnamed_file'.

Further, if you use the 'edit filename' function in the attachments section, the name param in the body are not updated accordingly and thus downloaded filenames for files taken from the text body will be wrong and remain as they were at insert-time.

So it seems like the solution is a bit more tricky and must involve updating img src attributes when anything changes.

Thanks a lot for the continuous updates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants