More Related Content
Similar to 沖縄Web+db勉強会 20121026
Similar to 沖縄Web+db勉強会 20121026 (20)
沖縄Web+db勉強会 20121026
- 2. 自己紹介
• Twitter:@shumach217
• 仕事:組み込み, Linux device driver, Hard ware
• 趣味:iOS, AWS等
• Web or DBははっきり言って素人ですwww。
- 12. system resource
• EC2, DynamoDB, S3を連携したシステム構築
• AWSのみで構築!!
• 本家Instagramを参考に!!
• 楽!!!!!!!
• Mac Book Air一つで作成可能!!
- 13. Instagram構成(blog)
• Load Blancing
• ELB + nginx
• App
• Django on EC2(High-CPU Extra-Large)
• S3
• Data Storage
• PostgreSQL + redis
- 17. 構成要素
• App
• Ruby on Rails on EC2(micro)
• S3
• Data Storage
• DynamoDB
• redisは近日中にトライ予定
- 18. Ruby on Railsの構成
• Paperclip
• DBとS3の連携
• Dynamoid
• ORM
• ActiveRecordは使用不可
• PaperclipをDynamoidで使用可能に
- 19. paperclip
• 画像はS3へ格納。
• S3はURLでファイルにアクセス。
• DBにURLを格納して画像と関連付け。
{“imageURL”, “http://hogehoge.com/hogeImage.png”}
- 20. Dynamoid
• DynamoDBを使用するためのORM
• idは昇順では無い!!
• 分散DBのため
• NoSQL
- 21. class PostImage
include Dynamoid::Document
include Dynamoid::Paperclip
field :name
field :caption, :serialized
field :like, :serialized
has_dynamoid_attached_file :image,
:path => ":attachment/:id/:style.:extension",
:storage => :s3,
:styles => {
:medium => "300x300>",
:thumb => "40x40>"
},
:s3_credentials => "#{Rails.root}/config/s3.yml"
attr_accessible :image
end
- 22. def create
@post_image = PostImage.new(:name => params[:post_image][:name])
@post_image.image = params[:post_image][:image]
@post_image.save
@post = Post.new(:name => params[:post_image][:name], :dest_id => @post_image.id.to_s,
:caption => params[:post_image][:caption])
@post.save
captions = Array.new
caption = {"name" => @post.name, "src_id" => @post.id.to_s, "caption" => @post.caption}
captions.push(caption)
@post_image.update_attribute(:caption, captions)
response = Array.new
content = {"name" => @post_image.name, "posted_id" => @post_image.id.to_s, "status" => "success"}
response_hash = {"feed" => content}
response.push(response_hash)
respond_to do |format|
format.json { render :json => response }
end
end
- 23. def create
@post_image = PostImage.new(:name => params[:post_image][:name])
@post_image.image = params[:post_image][:image]
@post_image.save
@post = Post.new(:name => params[:post_image][:name], :dest_id => @post_image.id.to_s,
:caption => params[:post_image][:caption])
@post.save
captions = Array.new
caption = {"name" => @post.name, "src_id" => @post.id.to_s, "caption" => @post.caption}
captions.push(caption)
@post_image.update_attribute(:caption, captions)
response = Array.new 連想配列の配列をそのまま格納
content = {"name" => @post_image.name, "posted_id" => @post_image.id.to_s, "status" => "success"}
response_hash = {"feed" => content}
response.push(response_hash)
respond_to do |format|
format.json { render :json => response }
end
end
- 24. class PostImage
include Dynamoid::Document
include Dynamoid::Paperclip
運用するならバージョン
field :version
field :context, :serialized
とそのテンプレートの方
has_dynamoid_attached_file :image,
:path => ":attachment/:id/:style.:extension",
:storage => :s3,
が楽??
:styles => {
:medium => "300x300>",
:thumb => "40x40>"
},
:s3_credentials => "#{Rails.root}/config/s3.yml"
attr_accessible :image
end
- 25. source code
• cloud
• https://github.com/shumach217/
shumachapp_rails_ojag20120811
• iOS
• https://github.com/shumach217/
shumachapp_ojag20120811
• http://www.slideshare.net/shumach217/
ojag20120811
- 26. まとめ
• Instagramを想定して、実装してみた。
• AWSのリソースを活用して、データの出し入
れは出来ました。
• iOSと連携しているので、興味がある方は声を
かけて頂ければデモ可能です!
- 27. 告知
• エンジニア忘年会の告知
• 12/1を予定!!
• 那覇近辺
• おすすめの場所があればリクエスト
• スクリーンが設置可能な場所w(必須)。
Editor's Notes
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n