Problem using readClipboard() in Shiny app deployed to shinyapps.io

127 views Asked by At

I have created a Shiny App that relies on reading data directly from the user's clipboard. This Shiny app works perfectly when running on my local machine; however when I deploy the app to shinyapps.io I get the following error:

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

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 :-(

Has anyone achieved this functionality before in a Shiny App deployed to shinyapps.io?

1

There are 1 answers

0
ViviG On

This is likely because shinyapps.io runs in a Linux server, and readClipboard()only works on Windows OS. So I am assuming that you are running locally on a Windows machine.

You could try the package clipr.

I never tried myself, but I read that it works on 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. This can be done using for example 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)

if (tolower(Sys.info()['sysname']) == "linux") {

# Linux code here

} else {

# Windows code here

}