在Rails中上传文件 [英] Uploading files in Rails
问题描述
我想在我的网站上创建一个访问者可以上传文件的部分(pdf)。如何才能做到这一点?
此外,在pdf上传后,我需要一个指向该文件的链接。我没有使用无聊的文本链接,而是想要在PDF的第一页上画一个缩略图。有没有一个工具可以做到这一点?
对于上传部分 acts href =http://techno-weenie.net/articles/acts_as_attachment =nofollow noreferrer> ActsAsAttachment 或者(如前所述) Paperclip 。
我不知道有什么插件可以创建/从PDF文件自动读取缩略图,但您可以调用 LibExtractpr 或 GhostScript 。
另外你可以看看 rGhost Gem (如文档所述)是一个文档创建和转换API,它本质上应该是一个Ruby的GhostScript包装器。
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.
这篇关于在Rails中上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!