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

后端 未结 6 1739
误落风尘
误落风尘 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:28

    In Paperclip 3.0.1 you could just use the io_adapter which doesn't require writing to (and removing from) the local file system.

    Paperclip.io_adapters.for(attachment.file).read
    

提交回复
热议问题