简体   繁体   English

在 Jupyter Notebook 中禁用“上传”

[英]Disable "Upload" in Jupyter notebook

I am using Amazon EC2 AMI deep learning.我正在使用 Amazon EC2 AMI 深度学习。 how can I revoke permission of uploading a file in jupyter notebook?如何撤销在 jupyter notebook 中上传文件的权限? Is there any way I can deny user from uploading any new files from their local machine?有什么办法可以拒绝用户从他们的本地机器上传任何新文件吗?

This is an open issue on the jupyter github: https://github.com/jupyter/jupyter/issues/293这是 jupyter github 上的一个未解决的问题: https : //github.com/jupyter/jupyter/issues/293

A way to disable downloading is described here: https://ujjwalbhardwaj.me/post/disable-download-button-on-the-sagemaker-jupyter-notebook此处描述了一种禁用下载的方法: https : //ujjwalbhardwaj.me/post/disable-download-button-on-the-sagemaker-jupyter-notebook

I haven't tested it myself, but I can image that overriding the files_handler_class with None in the latter example could also prevent uploads.我自己还没有测试过,但我可以想象在后一个例子中用None覆盖files_handler_class也可以阻止上传。

c.ContentsManager.files_handler_class = None

About three years after Logiza DevOps' answer: this is still an open issue on GitHub , albeit a different one (#7451).在 Logiza DevOps 的回答大约三年后:这仍然GitHub 上的一个悬而未决的问题,尽管是不同的问题 (#7451)。 The discussion revolves around making uploads extension-based so that they can be disabled.讨论围绕使上传基于扩展,以便它们可以被禁用。 The problem is that it is not sufficient to "make the Upload button disappear" because it is also possible to upload a file by simply dragging and dropping it over the notebook's File manager.问题在于“使上传按钮消失”是不够的,因为还可以通过简单地将文件拖放到笔记本的文件管理器上来上传文件。 In short, this is complicated:-(简而言之,这很复杂:-(

What's more: even if you could block file uploads, the user can still edit notebooks and other files through the Web GUI, so it's possible for instance to start some long-running CPU-intensive calculations on your notebook server.更重要的是:即使您可以阻止文件上传,用户仍然可以通过 Web GUI 编辑笔记本和其他文件,因此可以在您的笔记本服务器上启动一些长时间运行的 CPU 密集型计算。 I think you have no other choice but to trust your notebook users...我认为你别无选择,只能相信你的笔记本用户......

Slightly off-topic: as regards disabling downloads , there is now a Jupyter extension-based solution:有点题外话:关于禁用下载,现在有一个基于 Jupyter 扩展的解决方案:

jupyter labextension disable @jupyterlab/docmanager-extension:download
jupyter labextension disable @jupyterlab/filebrowser-extension:download
pip3 uninstall -y nbconvert

The nbconvert removal is necessary to prevent notebook conversion to PDF for instance.例如, nbconvert删除是防止笔记本转换为 PDF 所必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM