Hello RoR experts, I am trying to display a PDF stored out at Amazon S3 (private) using a keyed, expiring URL in a new window. I cannot display a direct link to the PDF (since it expires), instead I use a link to the show method, which does the following <div id="tt"> <embed src="<%= @book.file_path %>" width="100%" height="100%" allowfullscreen="true"> <script type="text/javascript"> $(''#tt'').show(); </script> <p></p> </div> (where @book.file_path returns the keyed URL to the PDF) This displays the PDF in a popup window however, I just want to display the PDF in a NEW browser window or, even better, in the native PDF viewer. I need to do this because on mobile devices (read iPad), this popup doesn''t work well. It draws the popup at the top of the page and the user cannot see it unless he/she scrolls to the top. Even if they do find it, the native behavior of the iPad PDF viewer--which is pretty nice--is not there. i.e. I want it to behave just like it would if the link were directly to the PDF. I have tried window.open(''mypdfpath'') and many other combinations. Is anyone doing this or have an idea how to approach it? TIA, Dan -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jens Fahnenbruck
2011-May-07 10:39 UTC
Re: Display PDF from Amazon S3 in new window for iPad etc.
Have you tried something like this: <%= link_to "LINKNAME", @book.file_path, :target => "_blank" %> Jens On Samstag, 7. Mai 2011 at 06:51, Dan Sadaka wrote: Hello RoR experts,> > I am trying to display a PDF stored out at Amazon S3 (private) using a > keyed, expiring URL in a new window. > > I cannot display a direct link to the PDF (since it expires), instead I > use a link to the show method, which does the following > > <div id="tt"> > <embed src="<%= @book.file_path %>" width="100%" height="100%" > allowfullscreen="true"> > <script type="text/javascript"> > $(''#tt'').show(); > </script> > <p></p> > </div> > > (where @book.file_path returns the keyed URL to the PDF) > > This displays the PDF in a popup window however, I just want to display > the PDF in a NEW browser window or, even better, in the native PDF > viewer. > > I need to do this because on mobile devices (read iPad), this popup > doesn''t work well. It draws the popup at the top of the page and the > user cannot see it unless he/she scrolls to the top. Even if they do > find it, the native behavior of the iPad PDF viewer--which is pretty > nice--is not there. i.e. I want it to behave just like it would if the > link were directly to the PDF. > > I have tried window.open(''mypdfpath'') and many other combinations. > > Is anyone doing this or have an idea how to approach it? > > TIA, > Dan > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jens, Thanks for the reply, I''m pretty sure that would work BUT--as I said in my post... I cannot display a direct link to the PDF (since it expires), instead I use a link to the show method So the link is sent from the show method and then opened at once. -Dan On May 7, 6:39 am, Jens Fahnenbruck <jig...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Have you tried something like this: > > <%= link_to "LINKNAME", @book.file_path, :target => "_blank" %> > > Jens > On Samstag, 7. Mai 2011 at 06:51, Dan Sadaka wrote: > Hello RoR experts, > > > > > > > > > > > I am trying to display a PDF stored out at Amazon S3 (private) using a > > keyed, expiring URL in a new window. > > > I cannot display a direct link to the PDF (since it expires), instead I > > use a link to the show method, which does the following > > > <div id="tt"> > > <embed src="<%= @book.file_path %>" width="100%" height="100%" > > allowfullscreen="true"> > > <script type="text/javascript"> > > $(''#tt'').show(); > > </script> > > <p></p> > > </div> > > > (where @book.file_path returns the keyed URL to the PDF) > > > This displays the PDF in a popup window however, I just want to display > > the PDF in a NEW browser window or, even better, in the native PDF > > viewer. > > > I need to do this because on mobile devices (read iPad), this popup > > doesn''t work well. It draws the popup at the top of the page and the > > user cannot see it unless he/she scrolls to the top. Even if they do > > find it, the native behavior of the iPad PDF viewer--which is pretty > > nice--is not there. i.e. I want it to behave just like it would if the > > link were directly to the PDF. > > > I have tried window.open(''mypdfpath'') and many other combinations. > > > Is anyone doing this or have an idea how to approach it? > > > TIA, > > Dan > > > -- > > Posted viahttp://www.ruby-forum.com/. > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-May-07 15:31 UTC
Re: Display PDF from Amazon S3 in new window for iPad etc.
On 7 May 2011 05:51, Dan Sadaka <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello RoR experts, > > I am trying to display a PDF stored out at Amazon S3 (private) using a > keyed, expiring URL in a new window. > > I cannot display a direct link to the PDF (since it expires), instead I > use a link to the show method, which does the following > > <div id="tt"> > <embed src="<%= @book.file_path %>" width="100%" height="100%" > allowfullscreen="true"> > <script type="text/javascript"> > $(''#tt'').show(); > </script> > <p></p> > </div> > > (where @book.file_path returns the keyed URL to the PDF) > > This displays the PDF in a popup window however, I just want to display > the PDF in a NEW browser window or, even better, in the native PDF > viewer.Could you just render the pdf from the show action? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Please explain this suggestion futher. Thanks, Dan On May 7, 11:31 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 7 May 2011 05:51, Dan Sadaka <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > > > > > > > > Hello RoR experts, > > > I am trying to display a PDF stored out at Amazon S3 (private) using a > > keyed, expiring URL in a new window. > > > I cannot display a direct link to the PDF (since it expires), instead I > > use a link to the show method, which does the following > > > <div id="tt"> > > <embed src="<%= @book.file_path %>" width="100%" height="100%" > > allowfullscreen="true"> > > <script type="text/javascript"> > > $(''#tt'').show(); > > </script> > > <p></p> > > </div> > > > (where @book.file_path returns the keyed URL to the PDF) > > > This displays the PDF in a popup window however, I just want to display > > the PDF in a NEW browser window or, even better, in the native PDF > > viewer. > > Could you just render the pdf from the show action? > > Colin-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Chris Mear
2011-May-08 20:02 UTC
Re: Display PDF from Amazon S3 in new window for iPad etc.
On 7 May 2011 05:51, Dan Sadaka <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello RoR experts, > > I am trying to display a PDF stored out at Amazon S3 (private) using a > keyed, expiring URL in a new window. > > I cannot display a direct link to the PDF (since it expires), instead I > use a link to the show method, which does the following > > <div id="tt"> > <embed src="<%= @book.file_path %>" width="100%" height="100%" > allowfullscreen="true"> > <script type="text/javascript"> > $(''#tt'').show(); > </script> > <p></p> > </div> > > (where @book.file_path returns the keyed URL to the PDF) > > This displays the PDF in a popup window however, I just want to display > the PDF in a NEW browser window or, even better, in the native PDF > viewer. > > I need to do this because on mobile devices (read iPad), this popup > doesn''t work well. It draws the popup at the top of the page and the > user cannot see it unless he/she scrolls to the top. Even if they do > find it, the native behavior of the iPad PDF viewer--which is pretty > nice--is not there. i.e. I want it to behave just like it would if the > link were directly to the PDF. > > I have tried window.open(''mypdfpath'') and many other combinations. > > Is anyone doing this or have an idea how to approach it?Can''t you just make ''show'' action redirect to the S3 URL (i.e. using the ''redirect_to'' method)? Chris -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Max Schubert
2011-May-08 20:30 UTC
Re: Display PDF from Amazon S3 in new window for iPad etc.
If the account / S3 URL should not be shown to the user, you could stream the pdf content to them directly with your app as the proxy and just set the appropriate http headers to give the user a suggested name for the content - doing it this way will trigger the browser to use whatever application is associated with PDF on their system to display the content. On 5/8/11, Chris Mear <chrismear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 7 May 2011 05:51, Dan Sadaka <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Hello RoR experts, >> >> I am trying to display a PDF stored out at Amazon S3 (private) using a >> keyed, expiring URL in a new window. >> >> I cannot display a direct link to the PDF (since it expires), instead I >> use a link to the show method, which does the following >> >> <div id="tt"> >> <embed src="<%= @book.file_path %>" width="100%" height="100%" >> allowfullscreen="true"> >> <script type="text/javascript"> >> $(''#tt'').show(); >> </script> >> <p></p> >> </div> >> >> (where @book.file_path returns the keyed URL to the PDF) >> >> This displays the PDF in a popup window however, I just want to display >> the PDF in a NEW browser window or, even better, in the native PDF >> viewer. >> >> I need to do this because on mobile devices (read iPad), this popup >> doesn''t work well. It draws the popup at the top of the page and the >> user cannot see it unless he/she scrolls to the top. Even if they do >> find it, the native behavior of the iPad PDF viewer--which is pretty >> nice--is not there. i.e. I want it to behave just like it would if the >> link were directly to the PDF. >> >> I have tried window.open(''mypdfpath'') and many other combinations. >> >> Is anyone doing this or have an idea how to approach it? > > Can''t you just make ''show'' action redirect to the S3 URL (i.e. using > the ''redirect_to'' method)? > > Chris > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Max, This sounds elegant but I haven''t a clue how to start doing it. :-) In this scenario, the PDF still moves directly from S3 to the user''s browser, correct? (It''s too slow to pull it locally and then send it.) If so, please send me to a reference for this or supply an example. Thanks, Dan On May 8, 4:30 pm, Max Schubert <max.schub...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If the account / S3 URL should not be shown to the user, you could > stream the pdf content to them directly with your app as the proxy and > just set the appropriate http headers to give the user a suggested > name for the content - doing it this way will trigger the browser to > use whatever application is associated with PDF on their system to > display the content. > > On 5/8/11, Chris Mear <chrism...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On 7 May 2011 05:51, Dan Sadaka <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> Hello RoR experts, > > >> I am trying to display a PDF stored out at Amazon S3 (private) using a > >> keyed, expiring URL in a new window. > > >> I cannot display a direct link to the PDF (since it expires), instead I > >> use a link to the show method, which does the following > > >> <div id="tt"> > >> <embed src="<%= @book.file_path %>" width="100%" height="100%" > >> allowfullscreen="true"> > >> <script type="text/javascript"> > >> $(''#tt'').show(); > >> </script> > >> <p></p> > >> </div> > > >> (where @book.file_path returns the keyed URL to the PDF) > > >> This displays the PDF in a popup window however, I just want to display > >> the PDF in a NEW browser window or, even better, in the native PDF > >> viewer. > > >> I need to do this because on mobile devices (read iPad), this popup > >> doesn''t work well. It draws the popup at the top of the page and the > >> user cannot see it unless he/she scrolls to the top. Even if they do > >> find it, the native behavior of the iPad PDF viewer--which is pretty > >> nice--is not there. i.e. I want it to behave just like it would if the > >> link were directly to the PDF. > > >> I have tried window.open(''mypdfpath'') and many other combinations. > > >> Is anyone doing this or have an idea how to approach it? > > > Can''t you just make ''show'' action redirect to the S3 URL (i.e. using > > the ''redirect_to'' method)? > > > Chris > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.