How do you access the raw content of a file uploaded with Paperclip / Ruby on Rails?

后端 未结 6 1738
误落风尘
误落风尘 2020-12-05 07:24

I\'m using Paperclip / S3 for file uploading. I upload text-like files (not .txt, but they are essentially a .txt). In a show controller, I want to be able to get the cont

6条回答
  •  有刺的猬
    2020-12-05 07:31

    You would need to load the contents of the file (using Rubys File.open) into a variable before you show it. This may be an expensive operation if your app gets lots of use, so it may be worthwhile reading the contents of the file and putting it into a text column in your database after uploading it.

提交回复
热议问题