- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
问题:
我有一个 Rails 应用程序,它要求用户上传某种类型的电子表格(csv、xslx、xsl 等)进行处理,这可能是一项成本高昂的操作,因此我们决定将其发送到后台服务作为解决方案到这个问题。我们关心的问题是,因为我们的生产系统是在 Heroku 上,所以我们需要先将文件存储在 AS3 上,然后再检索进行处理。
因为将文件上传到 AS3 本身就是一项成本高昂的操作,所以这也应该作为后台作业来完成。问题在于,由于 Resque 需要将文件数据放入 Redis 或稍后检索,因此使用 Resque 执行此操作可能会占用大量 RAM。如您所知,Redis 仅将其数据存储在 RAM 中,并且更喜欢简单的键值对,因此我们希望尽量避免这种情况。
下面是一些伪代码,作为我们想要尝试做的示例:
workers/AS3Uploader.rb
require 'fog'
class AS3Uploader
@queue = :as3_uploader
def self.perform(some, file, data)
# create a connection
connection = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => APP_CONFIG['s3_key'],
:aws_secret_access_key => APP_CONFIG['s3_secret']
})
# First, a place to contain the glorious details
directory = connection.directories.create(
:key => "catalog-#{Time.now.to_i}", # globally unique name
:public => true
)
# list directories
p connection.directories
# upload that catalog
file = directory.files.create(
:key => 'catalog.xml',
:body => File.open(blah), # not sure how to get file data here with out putting it into RAM first using Resque/Redis
:public => true
end
# make a call to Enqueue the processing of the catalog
Resque.enqueue(CatalogProcessor, some, parameters, here)
end
controllers/catalog_upload_controller.rb
def create
# process params
# call Enqueue to start the file processing
# What do I do here? I could send all of the file data here right now
# but like I said previously that means storing potentially 100s of MB into RAM
Resque.enqueue(AS3Uploader, some, parameters, here)
end
最佳答案
我建议你做的方式是
tmp
目录中并获取 file-path
Resque
使用 file-path
上传文件 Resque
将 file-path
存储在 redis
而不是整个 file-content
(它会很贵)AWS-S3
Note: If you have multiple instances like One instance for background processing, One for database, One as utility instance then your tmp dir may not be available to other instances.. so store the file in the
temp
dir inside the instance holding theresque
关于ruby-on-rails - rails : Uploading a file to AS3 using fog and resque,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32321015/
所以我是个新手,正在阅读 Michael Hartl 的 Rails 教程。尝试使用carrierwave、fog-aws 配置图片上传到S3 AWS 时,我完全陷入困境。推送到 heroku 时,出
我正在尝试制作一款即时战略游戏,例如《星际争霸》或《帝国时代》。我的 map 必须支持最多约 1500 个实体。我的问题是如何在不滞后游戏的情况下实现 war 迷雾。我最初尝试的方法是在每次移动时简单
我有一个 Rails 3.2 应用程序。使用 fog 在 S3 中存储文件。 我想写一个脚本来重命名所有已上传的文件。我似乎找不到这方面的任何雾文档。 雾有可能吗?我需要另一个 gem 吗? 最佳答案
我正在尝试查找有关如何设置Paperclip以使用fog.io和fog.io以使用Rackspace Cloud File的文档,但是我找不到任何好的引用文献(而且我认为自己是一位出色的Google语
我正在使用 ThreeJS 加载场景,如下所示: $(document).ready(function(){ var scene = new THREE.ObjectLoader().load
我已经为 Three.js 中的场景启用了雾。还有 Material 启用雾 bool 值。 当我重新加载页面并快速切换到另一个应用程序(或 Mac 上的另一个空间),然后返回到该站点时,雾可以正常工
我正在使用出色的 Fog gem 来访问 Rackspace 云文件服务。我面临的挑战是,我正在努力使访问 Cloud Files 的服务保持轻量级,而且 Fog 似乎通过其灵 active 具有很多
我正在开发一个允许商家上传他们商店图片的平台。我为此使用 Carrierwave+fog。由于该应用程序托管在 heroku 上,因此图片需要存储在 amazon s3 上。 在我的本地机器上,如果存
我正在尝试在我的模型中使用以下内容重新创建我上传的图像... Post.all.each do |ym| ym.avatar.cache_stored_file! ym.a
我正在尝试将 CarrierWave 与 Amazon S3 一起使用。当我尝试通过 rake 任务上传文件时,出现此错误: rake aborted! Expected(200) Actual(4
我正在使用 Carrierwave 0.5.3 和 Fog 将图像上传到 Amazon-S3。 在本地运行时,设置工作顺利,没有错误。 但是在 Heroku 上运行时,上传失败并显示以下消息: 201
我安装了 carrierwave gem 和 fog gem 以使用 Amazon s3。但是,在完成所有步骤之后,我尝试运行 rails s -p $PORT -b $IP 因为我使用的是 clou
我正在尝试使用 SKEmitterNode 创建着色器,有点像在洞穴中的口袋妖怪中: http://www.serebii.net/pokearth/maps/johto-hgss/38-route3
我正在尝试 ruby fog vsphere 示例: #!/usr/bin/env ruby require 'rubygems' require 'pp' require 'fog' requi
我应该如何在 App Fog 中迁移 Rails 应用程序数据库? 例如,在 Heroku 上,您必须在第一次部署后运行: $ heroku run rake db:migrate App Fog上是
我试过: my_directory.files.create(key: key, body: body, metadata: { custom: "x" }) 和: my_directory.fi
下午 StackOverflow, 我正在尝试使用 Fog & Ruby 在 OpenStack 上构建网络,但在准备好 API 文档后,我正在尝试构建的网络是通过网关构建的 here它说要在创建时禁
如何在 S3 中的现有文件或新创建的文件中附加文本。我正在使用 fog 并且我有以下代码 require 'fog' file = "abc.csv" bucket = 'my_bucket'
我在 Rails 应用程序中使用 CarrierWave/Fog 将视频上传到 Amazon S3。 有没有办法判断上传的进度,让我可以显示上传进度如何? 最佳答案 CarrierWave 和 Fog
我在 s3 上有一堆文件。我使用 .fog 配置文件设置了雾,这样我就可以启动 fog 并获得提示。如果我知道文件的路径,现在如何访问和编辑 s3 上的文件? 最佳答案 最简单的方法可能是使用 IRB
我是一名优秀的程序员,十分优秀!