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
JupyterLab fails to open files provided with FileLink does not allow to download them #5443
Comments
I'm trying to reproduce this. I figured out that I needed to do |
With a stock JLab with no special url prefix, using your code above (with
Clicking on the link opens it up in JLab. Shift-right-clicking on the link opens the browser context menu, which allows me to open the file in a new browser tab or downloading it. Is that what you were wanting? |
Perhaps the answer here is to use the browser context menu with shift-right-click? |
Yes, that would be a workaround. However, getting to the browser context menu via shift-right-click is quite hidden and it would be more convinient to offer the download if JLab is not able to open the file or if the file link has the download tag. Also this workaround does not allow to specify a different filename. For example in my case, I have a lot of files in a folder structure and I wrote a magic that selects some files based on some conditions. Since the selected files might have the same name in different directories or since the filename is also not very informative, I set a different filename in the download tag. With shift-right-click, the browser will store the file under its original name. |
Sorry, I forgot to specify this, I have updated my original post accordingly. The |
I can confirm this issue in JupyterLab 1.1.4. Following code shows it for Excel: (Or, instead of to_excel, just put some Excel file in notebook folder) When clicking the 'text.xslx' link displayed, JupyterLab tries to open the Excel and fails (File Load Error for test.xlsx - JupyterLab is unable to open this file type.). In Jupyter 6.0.1 it works as expected (clicking Excel file opens download dialog). Shift-right click does indeed work, but that's a workaround. |
The reason it works in the classic notebook is that the notebook punts to the browser to open a file in a new browser tab, and the browser realizes it can't show an excel file, so the browser offers the download. It would be great if JupyterLab had a plugin for a default behavior for files it can't open, such as downloading them. It will be a bit trickier than the notebook because jlab has to make the decision rather than just punting to the browser, but hopefully not any more tricky than the current right-click download option. |
I see, thanks for clarifying. |
The presumption here is that if an A node has a download attribute explicitly set, the user really does want to download the file rather than opening the file in JLab. Fixes jupyterlab#5443
Ah, actually the work should be much simpler - I forgot that you had the download attribute set in this link, which we could check for. I think what we need to do is, when analyzing links and deciding whether to imbue JLab behaviors on the link, we should just skip links that have the download attribute set, leaving the handling of the link to the browser. Indeed, I put this fix in #7311. |
This should be fixed in 1.2.0a1, released today. |
I implemented a magic command that selects some files on the server and should output a link that allows to download them. I extended the class FileLink as follows:
later, I call
So far, this all works, the links are displayed in the notebook, however, when I click them JupyterLab tries to open the file and fails since it is not able to open it (pickle-file). Still I also don't get the option to download the file. With the classic notebook everything works fine and also if I
tab + right mouse
-click on the link and open it in a new tab. In the latter case, I don't get it saved with the filename specified in thedownload
-tag though.The text was updated successfully, but these errors were encountered: