如何将文件作为参数从控制器发送到模型?
从控制器中,是否有一种方法可以使用文件作为参数来调用模型中的方法,而当您尝试在模型中使用接收到的文件时,不会出现未初始化的流错误?
我正在尝试使用 delayed_job 将文件上传到 S3 (使用 Paperclip)。我使用 Heroku,所以任何请求都会在 30 秒后超时,并且我想允许一次上传多个文件。
delayed_job Google 网上论坛也讨论了同样的问题,但一直没有解决办法。
From a controller, is there a way to call a method in a model with a file as a parameter, without getting an uninitialized stream error when you try to use the received file in the model?
I am trying to use delayed_job to upload files to S3 (using Paperclip). I use Heroku, so any request will time out after 30 secs, and I want to allow multiple file uploads at once.
The same problem was talked about in the delayed_job Google Group, but there was never a solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须先将文件保存在本地,或者直接保存到 S3,而不执行延迟作业。另一种选择是让用户直接上传到 S3,而不是通过堆栈 - 这种方法显然在身份验证和首先筛选数据的能力方面存在一些其他问题,但您可以在延迟的作业中处理数据筛选。
You'll have to save the file locally first, or directly to S3 without going through the delayed job. Another option would be to have the user upload directly to S3 rather than going through your stack - this approach obviously has some other issues around authentication and the ability to screen the data first, but you could handle the data screening in your delayed job instead.