You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
We fetch some binary PDF data and store it as an S3 attachment. The file name Paperclip assigns is "stringio.txt" and the content_type in Rails is nil; on S3 the metadata indicates the content_type is "text/plain". This causes a problem in Chrome as it doesn't deal with the download properly.
We're looking for a way to force the attachment's content_type. Below is what we've found but it seems uglier than necessary. Note that pdf_data is a method on the model that returns binary PDF data.
has_attached_file :pdf,
storage: :s3,
# etc
# before, getting text/plain as content_type set on S3
def render_pdf
self.pdf = StringIO.new(pdf_data)
save
end
# after, getting application/pdf as content_type on S3
def render_pdf
io = StringIO.new(pdf_data)
def io.content_type; 'application/pdf'; end
self.pdf = io
save
end
Any suggestions appreciated.
The text was updated successfully, but these errors were encountered:
Hi @Capncavedan ! Is this still an issue for you in Paperclip; I know this issue is from approximately 2 years ago. If it is still an issue, can you please provide the code that's causing you the error? Thanks!
We fetch some binary PDF data and store it as an S3 attachment. The file name Paperclip assigns is "stringio.txt" and the content_type in Rails is nil; on S3 the metadata indicates the content_type is "text/plain". This causes a problem in Chrome as it doesn't deal with the download properly.
We're looking for a way to force the attachment's
content_type
. Below is what we've found but it seems uglier than necessary. Note thatpdf_data
is a method on the model that returns binary PDF data.Any suggestions appreciated.
The text was updated successfully, but these errors were encountered: