上传使用红宝石与西纳特拉视频到Amazon S3 [英] Upload videos to Amazon S3 using ruby with sinatra

查看:214
本文介绍了上传使用红宝石与西纳特拉视频到Amazon S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Android应用程序有写在红宝石/西纳特拉后端。从Android应用程序中的数据即将在JSON数据的形式。 正在使用的数据库是MongoDB的。

I am building an android app which has a backend written on ruby/sinatra. The data from the android app is coming in the form of json data. The database being used is mongodb.

我能够捕捉数据的后端。现在,我想要做的是上传到Amazon S3的视频从Android应用程序发送的字节数组的形式。 我也想存储视频在一个字符串中的本地数据库的一种形式。 我一直在使用carrierwave,雾和carrierwave-mongoid宝石,但没有任何运气。

I am able to catch the data on the backend. Now what I want to do is to upload a video on Amazon S3 being sent from the android app in the form of byte array. I also want to store the video in a form of a string in the local database. I have been using carrierwave, fog and carrierwave-mongoid gems but didn't have any luck.

以上是一些博客我也跟着:

These are the some blogs I followed:

https://blog.engineyard.com/2011/a - 温和介绍到carrierwave /

http://www.javahabit.com/2012/06/03/saving-files-in-amazon-s3-using-carrierwave-and-fog-gem/

如果有人可能只是指导我,如何去了解它专门与西纳特拉和MongoDB的导致这就是我现在所面临的主要问题。

If someone could just guide me with how to go about it specifically with sinatra and mongodb cause that's where I am facing the main issue.

推荐答案

您可能会考虑使用AWS SDK为Android直接上传到S3,使您的应用程序服务器线程没有得到而一个用户上传文件卡住。如果你使用的是像Heroku的服务,你将支付额外的$$$只是因为你的用户有一个糟糕的连接。

You might think about using AWS SDK for Android to directly upload to S3 so that your app server thread doesn't get stuck while an user is uploading a file. If you are using a service like Heroku you would be paying extra $$$ just because your user had a lousy connection.

然而,在这种情况下;

However in this scenario;

上传到S3应该是简单的,一旦你有你的地方安装使用carrierwave。

Uploading to S3 should be straight forward once you have your mounting in place using carrierwave.

您永远不应该存储你的视频在数据库中,因为它会让你放慢脚步! DB均不能在档案的优化,操作系统是。视频是二进制数据,不能存储为文本,你需要一个BLOB类型,如果你想这样做的犯罪。

You should never store your video in the database as it will slow you down! DBs are not optimised for files, OSs are. Video is binary data and cannot be stored as text, you would need a blob type if you want to do this crime.

IMO,上传到S3是足够好,那么你就可以使用Amazon CloudFront的CDN服务,以复制和分发您的内容以更优化的方式。

IMO, uploading to S3 is good enough as then you can use Amazon cloudfront CDN services to copy and distribute your content in a more optimised way.

这篇关于上传使用红宝石与西纳特拉视频到Amazon S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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