alternative to www when no writing authorization

55 views
Skip to first unread message

Stéphane Laurent

unread,
Oct 22, 2013, 6:59:35 AM10/22/13
to shiny-...@googlegroups.com
Hello, 

I have a Shiny app creating a pdf file and I embed it like that:

tags$object(data="myplot.pdf", type="application/pdf", width="550px", 
                                          height="400px")

It works if myplot.pdf is in the www subfolder, otherwise it does not work (even by specifying the full path of the file). This is problematic because I use the Shniy Server in my company and the user has not authorization to write on the server. 

Joe Cheng

unread,
Oct 24, 2013, 12:51:07 AM10/24/13
to Stéphane Laurent, shiny-...@googlegroups.com
Does the downloading feature not work for your case?


--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Stéphane Laurent

unread,
Oct 24, 2013, 2:06:03 AM10/24/13
to shiny-...@googlegroups.com, Stéphane Laurent
Yes of course the downloadhandler works. But I want a pdf preview in the app.

Joe Cheng

unread,
Oct 24, 2013, 1:54:34 PM10/24/13
to Stéphane Laurent, shiny-...@googlegroups.com
(oops, dropped shiny-discuss from my last reply accidentally)

You could also (ab)use addResourcePath, I suppose. Map a URL to a temp dir.


On Thu, Oct 24, 2013 at 9:50 AM, Joe Cheng <j...@rstudio.com> wrote:
Oh sorry, I misread tags$object as being a link. I get it now.

Maybe if you encode the PDF into a data URI and use that as the data?

uri <- paste0("data:application/pdf;base64,", base64encode(readBin(file, "raw", n=file.info(file)$size)))

Pretty sure this would not work on IE though, so if you need that then it's a problem.

Stéphane Laurent

unread,
Oct 24, 2013, 2:39:05 PM10/24/13
to shiny-...@googlegroups.com, Stéphane Laurent
Thank you very much. I will soon try your suggestions. 
But using tags$object(),  I'm not sure the pdf preview will be updated if the pdf file changes ?

Joe Cheng

unread,
Oct 24, 2013, 5:06:53 PM10/24/13
to Stéphane Laurent, shiny-...@googlegroups.com
Not automatically, no. You'll need to regenerate the object tag, probably, using renderText with htmlOutput or whatever. If you're going to overwrite the same PDF file over and over, then I recommend you append some random bytes as a querystring, like http://foo/bar/output.pdf?nonce=23908432984
Reply all
Reply to author
Forward
0 new messages