I''m building an app that lets users post documents that other users can view. The format to the type of document doesn''t hold up with a cut and paste so they have to upload. My question is how to display the content of a document uploaded to the site without the user having to download the file. Any help would be great. Thanks J -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
it''s going to depend on the type of document. On 2/27/07, Jason Gagne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m building an app that lets users post documents that other users can > view. The format to the type of document doesn''t hold up with a cut and > paste so they have to upload. My question is how to display the content > of a document uploaded to the site without the user having to download > the file. Any help would be great. > > Thanks > > J > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I agree with Chris... it can vary very widely depending on the type of document... basically, what you need is a way to parse the document on the server and display it in the page as HTML... HTML being one of the very few things you can push across the internet and expect someone to receive... there are converters for a lot of different document types, you could possibly conceivably generate an image of the document somehow, etc... but it will all hinge on what kind of document it is. On 2/27/07, Chris Hall <christopher.k.hall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > it''s going to depend on the type of document. > > On 2/27/07, Jason Gagne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > I''m building an app that lets users post documents that other users can > > view. The format to the type of document doesn''t hold up with a cut and > > paste so they have to upload. My question is how to display the content > > of a document uploaded to the site without the user having to download > > the file. Any help would be great. > > > > Thanks > > > > J > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
To add to Luke and Chris - Also be aware that it will be your hosting server doing the reading before any document is served. e.g. If you upload a powerpoint file from a windows machine, the server would need converters/readers to read that file type. Might be easy for a text document. If you are storing the file on the server, you could simple use # Return the contents of a file as a string def file_to_str(filename) rv = "" if File.exist?(filename) == false rv = nil else File.open(filename, "rb") do |infile| rv = infile.read end end rv end to retrieve the file contents as string and serve it any way you want. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
my experience with handling document assets on the web, be they word docs, pdfs, spreadsheets, whatever, is that you should rely on the browser and OS to handle the display. No matter how you look at it, the file data has to be ''downloaded'', whether it''s displayed in the page as html or via a plugin or opened in Word. all you should worry about is setting the correct headers then sending the data. ex: i click a link to a Word document, Open Office opens to display the document. I click on a pdf document and the Acrobat plugin displays the document within the browser. Chris On 2/27/07, Chet <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > To add to Luke and Chris - > > Also be aware that it will be your hosting server doing the reading > before any document is served. e.g. If you upload a powerpoint file from > a windows machine, the server would need converters/readers to read that > file type. > > Might be easy for a text document. If you are storing the file on the > server, you could simple use > > # Return the contents of a file as a string > def file_to_str(filename) > rv = "" > > if File.exist?(filename) == false > rv = nil > else > File.open(filename, "rb") do |infile| > rv = infile.read > end > end > rv > end > > to retrieve the file contents as string and serve it any way you want. > > > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The docs will be limited to pdf files. So, if the OS handles the display, the view should just link_to what, the file itself or is there a method that needs to be called on it to tell the os have the Acrobat plugin display it? Sorry for the rookie questions but, I''m a rookie. Thanks for all the help J Chris Hall wrote:> my experience with handling document assets on the web, be they word > docs, pdfs, spreadsheets, whatever, is that you should rely on the > browser and OS to handle the display. No matter how you look at it, > the file data has to be ''downloaded'', whether it''s displayed in the > page as html or via a plugin or opened in Word. all you should worry > about is setting the correct headers then sending the data. > > ex: i click a link to a Word document, Open Office opens to display > the document. I click on a pdf document and the Acrobat plugin > displays the document within the browser. > > Chris-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Your browser should handle a link to a pdf if you have the plugin or reader installed. Worse case is your browser will open a dialog and ask if you want to save or open with whatever your default viewer is set to. I believe that with the Acrobat plugin, it will open the document directly in the browser. one thing i''ve done in the past is have an iframe setup for displaying documents using the acrobat plugin. you can then target that iframe from the link and the acrobat plugin should open within the targeted iframe and display your document. Chris On 2/27/07, Jason Gagne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > The docs will be limited to pdf files. So, if the OS handles the > display, the view should just link_to what, the file itself or is there > a method that needs to be called on it to tell the os have the Acrobat > plugin display it? Sorry for the rookie questions but, I''m a rookie. > > Thanks for all the help > > J > Chris Hall wrote: > > my experience with handling document assets on the web, be they word > > docs, pdfs, spreadsheets, whatever, is that you should rely on the > > browser and OS to handle the display. No matter how you look at it, > > the file data has to be ''downloaded'', whether it''s displayed in the > > page as html or via a plugin or opened in Word. all you should worry > > about is setting the correct headers then sending the data. > > > > ex: i click a link to a Word document, Open Office opens to display > > the document. I click on a pdf document and the Acrobat plugin > > displays the document within the browser. > > > > Chris > > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---