开发者

Paperclip.run 'jpegoptim' - problem with params

In my model, that has_at开发者_运维技巧tached_file, I have the following code:

before_post_process :jpeg_optim_compression

...

def jpeg_optim_compression
  path = attachment.queued_for_write[:original].path
  Paperclip.run("jpegoptim", "-o --strip-all #{path}")
end

And locally it works fine giving a following output:

[paperclip] jpegoptim -o --strip-all temporary_path_to_attachment  2>/dev/null

But deployed on the staging server it raises an error:

[paperclip] jpegoptim '-o --strip-all temporary_path_to_attachment' 2>/dev/null

Paperclip::PaperclipCommandLineError (Error while running jpegoptim. Expected return code to be 0 but was 3):

It took me some time to realize that these quotations were the cause (I supposed some file access problem and others). After change to

Paperclip.run("jpegoptim -o --strip-all #{path}")

OR

Paperclip.run("jpegoptim -o --strip-all", "#{path}")

it works. Does anybody have an idea why is that?

Thanks for any suggestions!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜