Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GuruSP - Solucionando o problema de Uploads em...
Search
Rafael Macedo
June 21, 2014
Programming
120
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GuruSP - Solucionando o problema de Uploads em Apps no Heroku
Rafael Macedo
June 21, 2014
More Decks by Rafael Macedo
See All by Rafael Macedo
Modularização de código JS
macedorafael
0
240
TDC 2014 - Solucionando o problema de Uploads em Apps no Heroku
macedorafael
1
170
Aplicações Realtime com XMPP
macedorafael
3
220
Web in the cloud with ruby
macedorafael
2
400
Other Decks in Programming
See All in Programming
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
320
Oxlintのカスタムルールの現況
syumai
6
1k
Oxcを導入して開発体験が向上した話
yug1224
4
290
TAKTでAI駆動開発の品質を設計する
j5ik2o
6
1k
AI時代のUIはどこへ行く?その2!
yusukebe
19
6.8k
AIで効率化できた業務・日常
ochtum
0
110
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.5k
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
260
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
Claspは野良GASの夢をみるか
takter00
0
170
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
230
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
0
170
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
107
250k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Designing Experiences People Love
moore
143
24k
Balancing Empowerment & Direction
lara
6
1.1k
Code Review Best Practice
trishagee
74
20k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
340
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
190
Writing Fast Ruby
sferik
630
63k
Transcript
Solucionando o problema de Uploads em Apps no Heroku
@macedorafael http://github.com/macedo Rafael Macedo
@macedorafael http://github.com/macedo Macedo
backend…
…com chapéu de front
None
None
None
“O que pode dar errado num mero upload de uma
foto?”
None
30 segundos
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser
None
…
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
! ! ! ! Unicorn Rails AWS S3 Image Magick
Browser ! ! ! ! Resque/Sidekiq Worker
heroku addons
None
Blitline
Blitline Transloadit
Blitline Transloadit Cloudinary
Blitline Transloadit Cloudinary ✔
http://cloudinary.com
None
None
upload
None
•JPG, PNG, GIF, BMP, ICO, TIFF and PDF
•JPG, PNG, GIF, BMP, ICO, TIFF and PDF •Secure HTTP
upload API
•JPG, PNG, GIF, BMP, ICO, TIFF and PDF •Secure HTTP
upload API •Upload from your server or directly from the browser
storage
None
•Cloud-based persistent storage
•Cloud-based persistent storage •Highly available redundant storage
•Cloud-based persistent storage •Highly available redundant storage •S3
delivery
None
•Fast delivery (CDN)
•Fast delivery (CDN) •Smart caching
image transformation/ manipulation
None
resize
resize filter
resize filter crop
resize filter crop rotate
resize filter crop rotate face detection
resize filter crop rotate face detection chained transformation …
{"public_id"=>"fe23qemppmcorq0grmfv", "version"=>1403326723, "signature"=>"4e1a7bb2e3f3eb05eed25eed10cb09807561a764", "width"=>533, "height"=>300,
"format"=>"jpg", "resource_type"=>"image", "created_at"=>"2014-‐06-‐21T04:58:43Z", "bytes"=>13895, "type"=>"upload", "etag"=>"30b1c1b426db36b8e8c12d15d629fdb5", "url"=>"http://res.cloudinary.com/hxjx3jqm7/image/upload/v1403326723/ fe23qemppmcorq0grmfv.jpg", "secure_url"=>"https://res.cloudinary.com/hxjx3jqm7/image/upload/v1403326723/ fe23qemppmcorq0grmfv.jpg"}
{"public_id"=>"fe23qemppmcorq0grmfv", "version"=>1403326723, "signature"=>"4e1a7bb2e3f3eb05eed25eed10cb09807561a764", "width"=>533, "height"=>300,
"format"=>"jpg", "resource_type"=>"image", "created_at"=>"2014-‐06-‐21T04:58:43Z", "bytes"=>13895, "type"=>"upload", "etag"=>"30b1c1b426db36b8e8c12d15d629fdb5", "url"=>"http://res.cloudinary.com/hxjx3jqm7/image/upload/v1403326723/ fe23qemppmcorq0grmfv.jpg", "secure_url"=>"https://res.cloudinary.com/hxjx3jqm7/image/upload/v1403326723/ fe23qemppmcorq0grmfv.jpg"}
http://res.cloudinary.com/hxjx3jqm7/image/ upload/v1403326723/ fe23qemppmcorq0grmfv.jpg
http://res.cloudinary.com/hxjx3jqm7/image/ upload/v1403326723/ fe23qemppmcorq0grmfv.jpg
http://res.cloudinary.com/hxjx3jqm7/image/ upload/v1403326723/ fe23qemppmcorq0grmfv.jpg http://res.cloudinary.com/hxjx3jqm7/image/ upload/w_160,h_160,c_thumb,g_face/ fe23qemppmcorq0grmfv.jpg
http://res.cloudinary.com/hxjx3jqm7/image/ upload/v1403326723/ fe23qemppmcorq0grmfv.jpg http://res.cloudinary.com/hxjx3jqm7/image/ upload/w_160,h_160,c_thumb,g_face/ fe23qemppmcorq0grmfv.jpg
None
gem 'cloudinary'
# config/cloudinary.yml development: cloud_name:
“sample” api_key: “912739217312873” api_secret: “a123=asdaszad34dsf”
cl_image_tag(“e23qemppmcorq0grmfv.jpg”,
width: 160, height: 160, crop: fill, effect: ”sepia” )
cl_image_tag(“e23qemppmcorq0grmfv.jpg”,
effect: )
cl_image_tag(“e23qemppmcorq0grmfv.jpg”,
width: 100, height: 150, effect: :pixelate)
cl_image_tag(“e23qemppmcorq0grmfv.jpg”,
cl_image_tag(“e23qemppmcorq0grmfv.jpg”,
class ImageUploader < CarrierWave::Uploader::Base include Cloudinary::CarrierWave
version :standard do process :resize_to_fill => [100, 150, :fill] cloudinary_transformation quality: 80 end version :thumbnail do process :eager => true cloudinary_transformation transformation: [ { width: 100, height: 100, crop: :thumb, gravity: :face }, { overlay: ”watermark”, width: 30, hgravity: :south_east, x: 5, y: 5 } ] end end
class ImageUploader < CarrierWave::Uploader::Base include Cloudinary::CarrierWave
version :standard do process :resize_to_fill => [100, 150, :fill] cloudinary_transformation quality: 80 end version :thumbnail do process :eager => true cloudinary_transformation transformation: [ { width: 100, height: 100, crop: :thumb, gravity: :face }, { overlay: ”watermark”, width: 30, hgravity: :south_east, x: 5, y: 5 } ] end end
class ImageUploader < CarrierWave::Uploader::Base include Cloudinary::CarrierWave
version :standard do process :resize_to_fill => [100, 150, :fill] cloudinary_transformation quality: 80 end version :thumbnail do process :eager => true cloudinary_transformation transformation: [ { width: 100, height: 100, crop: :thumb, gravity: :face }, { overlay: ”watermark”, width: 30, hgravity: :south_east, x: 5, y: 5 } ] end end
class ImageUploader < CarrierWave::Uploader::Base include Cloudinary::CarrierWave
version :standard do process :resize_to_fill => [100, 150, :fill] cloudinary_transformation quality: 80 end version :thumbnail do process :eager => true cloudinary_transformation transformation: [ { width: 100, height: 100, crop: :thumb, gravity: :face }, { overlay: ”watermark”, width: 30, hgravity: :south_east, x: 5, y: 5 } ] end end
class ImageUploader < CarrierWave::Uploader::Base include Cloudinary::CarrierWave
version :standard do process :resize_to_fill => [100, 150, :fill] cloudinary_transformation quality: 80 end version :thumbnail do process :eager => true cloudinary_transformation transformation: [ { width: 100, height: 100, crop: :thumb, gravity: :face }, { overlay: ”watermark”, width: 30, hgravity: :south_east, x: 5, y: 5 } ] end end
class ImageUploader < CarrierWave::Uploader::Base include Cloudinary::CarrierWave
version :standard do process :resize_to_fill => [100, 150, :fill] cloudinary_transformation quality: 80 end version :thumbnail do process :eager => true cloudinary_transformation transformation: [ { width: 100, height: 100, crop: :thumb, gravity: :face }, { overlay: ”watermark”, width: 30, hgravity: :south_east, x: 5, y: 5 } ] end end
class Advertisement < ActiveRecord::Base ... mount_uploader
:image, ImageUploader ... end
= form_for(:advertisement) do |f| = f.hidden_field(:image_cache)
= f.file_field(:image)
None
# app/assets/javascripts/application.js //= require cloudinary
= form_for(:advertisement) do |f| ...
= cloudinary_js_config = f.cl_image_upload(:image) ..
= form_for(:advertisement) do |f| ...
= cloudinary_js_config = f.cl_image_upload(:image) ..
= form_for(:advertisement) do |f| ...
= cloudinary_js_config = f.cl_image_upload(:image) ..
None
$$$
None
10 GB Storage
10 GB Storage 40 GB Bandwidth
Cloudinary
$35
S3
$7
None
None
$7
$42
Conclusão
“O que pode dar errado num mero upload de uma
foto?”
Muita coisa!
None
Processamento background
Processamento background Direct Upload
None
OBRIGADO
OBRIGADO ?