简体   繁体   中英

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 env 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM