[英]Problem using readClipboard() in Shiny app deployed to shinyapps.io
I have created a Shiny App that relies on reading data directly from the user's clipboard.我创建了一个 Shiny App,它依赖于直接从用户的剪贴板读取数据。 This Shiny app works perfectly when running on my local machine;这个 Shiny 应用程序在我的本地机器上运行时运行良好; however when I deploy the app to shinyapps.io I get the following error:但是,当我将应用程序部署到 Shinyapps.io 时,出现以下错误:
Warning: Error in readClipboard: could not find function "readClipboard"
This question was raised before but didn't receive an answer: Paste from client's clipboard on Shiny Server之前提出过这个问题,但没有得到答案: 从客户端剪贴板粘贴到 Shiny 服务器上
My hunch is that I'll probably need to incorporate some javascript function which allows the web browser to read the user's clipboard...but I have zero idea where to start on that :-(我的直觉是,我可能会需要纳入一些JavaScript功能,它允许Web浏览器来读取用户的剪贴板...但我有零知道从哪里开始对:-(
Has anyone achieved this functionality before in a Shiny App deployed to shinyapps.io?有没有人在部署到 Shinyapps.io 的 Shiny App 中实现过这个功能?
This is likely because shinyapps.io runs in a Linux server, and readClipboard()
only works on Windows OS.这可能是因为 Shinyapps.io 在 Linux 服务器中运行,而readClipboard()
仅适用于 Windows 操作系统。 So I am assuming that you are running locally on a Windows machine.所以我假设您在 Windows 机器上本地运行。
You could try the package clipr .你可以试试包clipr 。
I never tried myself, but I read that it works on Linux.我自己从未尝试过,但我读到它可以在 Linux 上运行。 From the site where I read about the package 从我阅读有关包裹的网站
Note that on Linux, you will need to install the system requirement, either xclip or xsel.请注意,在 Linux 上,您需要安装系统要求,xclip 或 xsel。 This can be done using for example apt-get install xclip.这可以使用例如 apt-get install xclip 来完成。
I have an app running on a Linux server, and I use the following statement to be able to test it in Windows (in my case is access to a database that is different between systems)我有一个在 Linux 服务器上运行的应用程序,我使用以下语句能够在 Windows 中对其进行测试(在我的情况下是访问不同系统之间的数据库)
if (tolower(Sys.info()['sysname']) == "linux") {
# Linux code here
} else {
# Windows code here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.