开发者

Rails Paperclip - download file got corrupted

I am using paperclip for attachments

when i download file, it got corrupted.

File is download-able at production

send_file attachment.data.path, :type => attachment.content_type, :x_sendfile => true, :stream => false

it is working fine at local machine but it gives problem in production however i have set e开发者_如何学Cnv as production


The first thing to do is to check what is the file you are trying to send.

Add this line of code before your send_file statement:

logger.info "SENDING FILE: #{attachment.data.path.inspect}"

Then see the log, check the path and see whether the file really is there.

I suspect that your production and development modes have different database data (and this is natural and expected), but the files saved in the filesystem are not in synchronization with the databases.

It is possible that there is some other difference between environments, but the path is the first thing I would consider guilty.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜