简体   繁体   中英

Uploading files in Rails

I want to make a section in my site where visitors can upload files (pdfs). How can this be done?

Also, after the pdf is uploaded, I need a link to that file. Rather than using a boring text link, I was thinking of having a thumbnail graphic of the first page of the pdf. Is there a tool out there that does this?

For the Uploading part you might consider ActsAsAttachment or (as already stated) Paperclip .

I am not aware of any plugin for rails which is able to create/read thumbnails from PDF files automatically, but you could invoke LibExtractpr or GhostScript from your code.

Additionally you might take a look at the rGhost Gem which (as the documentation states) is a "a document creation and conversion API" which essentially should be a GhostScript Wrapper for Ruby.

Whilst, not directly addressing the PDF thumbnail issue "The Rails Way" is doing a series on uploading/downloading files with Rails which would be useful with large files like your PDFs.

Uploading Files : basically, they have an Apache module called ModPorter which speeds up the parsing of the multipart HTTP request containing the upload.

Downloading Files : use X-SendFile to let Apache serve the download, once your Rails app has performed any user authentication required

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM