Uploading files in Rails

后端 未结 2 1160
野的像风
野的像风 2021-01-24 02:17

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 th

相关标签:
2条回答
  • 2021-01-24 02:58

    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.

    0 讨论(0)
  • 2021-01-24 03:20

    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

    0 讨论(0)
提交回复
热议问题