【发布时间】:2014-07-08 09:23:42
【问题描述】:
我正在使用以下代码将生成的 CSV 文件上传到 S3。
现在,目前整个过程正在运行,但文件被存储为“文本/纯文本”。如果我将内容类型验证更改为使用“text/csv”,则会失败并出现内容类型验证错误。
为了简洁起见,我删除了一些代码
class Export < ActiveRecord::Base
has_attached_file :export_file
validates_attachment_content_type :export_file, :content_type => "text/plain"
public
def export_leave_requests
... csv generated in memory here ...
self.update_attributes(export_file: StringIO.new(csv_file))
self.save!
end
end
如何才能将 content_type 设置为 CSV?
【问题讨论】:
标签: ruby-on-rails-4 amazon-s3 paperclip