Search code examples
rdropboxshiny

Creating png file on dropbox for shiny app


I'm actually creating a shiny app that is hosted on shinyapps.io. To read and use my data I communicate with a dropbox account with rdrop2 package. I'd like to create a png file according to the user's input on my dropbox. Usually, I create png file on my working directory like that :

png("test.png") 
plot(...) 
dev.off()

I don't save just plots as PNG but also grid.tables.

I can get a file from my dropbox with 'drop_get' function.

My only problem is that I don't know how to save my instantly created png directly on my dropbox. I tried to save my PNG file in a variable like varPNG<-png('test.png')... and saved it with 'drop_upload' function but it doesn't work.

Can someone help me ?


Solution

  • EDIT: I'm not familiar enough with shiny app to help, sorry. Though I did find this thing: http://shiny.rstudio.com/gallery/image-output.html which might help you out.

    Basically it seems shiny has a renderImage function to manage the creation of images. Hope this helps.

    OLD ANSWER:

    The documentation for the package is here for reference.

    Make sure you have allowed rdrop2 to access your dropbox (see link)!

    From the link:

    write.csv(mtcars, 'mtcars.csv')
    drop_upload('mtcars.csv')
    # or upload to a specific folder
    drop_upload('mtcars.csv', dest = "drop_test")
    
    You can also do this for any other file type and large files are supported regardless of your memory.
    

    So you shouldn't store your image in a variable and try and upload that. Instead save your file as you would do as usual and then do:

    drop_upload("filename.png")