如何使用回形针与导轨,它是如何部署的? [英] How to use paperclip with rails and how does it work in deployment?

查看:125
本文介绍了如何使用回形针与导轨,它是如何部署的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了2涉及图像上传与回形针Rails应用。第一个我做了前一段时间工作的罚款当地,但我有问题,当我部署到Heroku上;我意识到我需要使用AWS,使图像上传。

I've done 2 Rails apps involving image uploads with paperclip. The first one I did a while ago worked fine locally but I had issues when I deployed to Heroku; I realized I needed to use AWS to enable image uploads.

我前一段时间做了该项目。最近,我开始另一个项目,并试图将类似的功能。在我启用了AWS使用回形针,当我试图部署,我只是想测试,如果我尝试上传的图像会发生什么。令我惊讶的是,它的工作没有AWS!我希望能理解为什么它的第一次没有工作,为什么它现在的工作。如何与Heroku和导轨在幕后做回形针工作?

I did that project a while ago. I recently started another project and tried to incorporate similar functionality. Before I enabled AWS with paperclip when I tried to deploy, I just wanted to test what would happen if I tried to upload an image. To my surprise, it worked without AWS! I was hoping to understand why it didn't work the first time and why it does work now. How does paperclip work with heroku and rails behind the scenes?

推荐答案

这可能是第一个应用托管于中的传统的竹子堆,即有一个只读文件系统

It's likely the first application was hosted on the legacy Bamboo stack, that had a read-only file system.

在href="https://devcenter.heroku.com/articles/cedar" rel="nofollow">新的雪松栈的临时文件系统。

In the new Cedar stack, the file system is no longer read-only, so the upload will not fail. However, you should keep using AWS or any other external storage because Heroku distributes your compiled application across several machines, and it's not guaranteed that the image will be visible from another request. They call it ephemeral filesystem.

在换句话说,竹叠加很容易理解,你不能存储在文件系统上的文件,因为你遇到了一个立即崩溃。雪松上传成功,但上传的图片将无法在任何时候的未来。

In other words, with the Bamboo stack it was easy to understand that you could not store files on the file system, because you were experiencing an immediate crash. With Cedar the upload succeeds, but the uploaded image will be unavailable at anytime in the future.

这个故事的寓意是:您应该继续使用AWS或Heroku的文件系统以外的任何其他存储

这篇关于如何使用回形针与导轨,它是如何部署的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆