shutterbug 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDhhMGNiMWQ4MGY0Yzc3N2FkNWEyYWY4OWMyYjhmOTgzYWE3YjBlYg==
4
+ Yjg4MjkzMTJhYzExYTVjMWRlMjA3NjJlMzZkOGQwNTRlNGQ1OWVkYg==
5
5
  data.tar.gz: !binary |-
6
- ZjM4NDMyODcyYWIxNWJjN2FkN2MzZjRjMjA2NDExODBjNGZmODFlOQ==
6
+ NDYwOGE0ZTM2ZDllOTU4MDVlMTg5N2Y5MzhiMWRiODU3ZDZlZDQ1Ng==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTk4ZTlhOGYxOTBiMGY2OTE0ZDc2YThlMjE4MDI2NzNhZmY1ZmMwYTVhYjE2
10
- ZjhjNTUzMzY4MTMzYWQyMWQ4YmM0ZDM2Yzk2NDhlNjk2MjIyNTM3MDRjOWIx
11
- ODU2ZWFhMzU5OGVkNDZiMzdhZDA5MDhjNjBmZGVmZDg5ZjA0OWQ=
9
+ OTcwODhkNGNlZmVhNmY4N2ZkY2RhZWYzYzg1M2EzNWQxOTQyYjIzZjI2ZmEy
10
+ N2YzMzkwNDk5ZmJlY2MxZmNiNmQ5MDJmZTI0MjgwZDRjYTk4NjU1MWFlNzM2
11
+ ZjIyYjdiMDUwZjU2NDMxNDBjOWM0Y2NjOGQ1ZjJlOTNjYjQxMDU=
12
12
  data.tar.gz: !binary |-
13
- NTkwNDc5OTFkNWRiNjMxNzEyMTg2NjRiMTY2MjRiODEwMjcwMmU5NWRlMWJk
14
- Zjk0MDE2YTdjN2IyM2Q3M2VhNmIwZTA3YmJmOGYxMjM0ZDUxNmY2ZTM3ODNl
15
- ODIyNDAwNjcwNDU3NjdkZWQ4ZTA3MzU2YmU4ZjcyZDJjNDA1NTM=
13
+ NzA5YWViZWZjOTJhZTQ0YjE5NjM3NjczMjdlM2VlOWM1OTZkYWM3Y2U3Y2Ni
14
+ MTg4ZjE4ZDY2Y2UwMjg2YjU4Y2VmZjExNDE3NDRlMTAzZWEyYmI0N2JhZGNi
15
+ YmExY2MyNzQ5NTFlMTk3MjAzMzI2MGI0NzAzNzA3MjYwZTVjNzg=
data/config.ru CHANGED
@@ -14,6 +14,7 @@ use Shutterbug::Rackapp do |config|
14
14
  config.s3_key = ENV['S3_KEY']
15
15
  config.s3_secret = ENV['S3_SECRET']
16
16
  config.s3_bin = "ccshutterbugtest"
17
+ # config.skip_direct_upload = true
17
18
  end
18
19
 
19
20
  app = Rack::Directory.new "demo"
data/lib/shutterbug.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Shutterbug
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  autoload :Rackapp, "shutterbug/rackapp"
4
4
  autoload :Configuration, "shutterbug/configuration"
5
5
  autoload :Storage, "shutterbug/storage"
@@ -10,6 +10,7 @@ module Shutterbug
10
10
  attr_accessor :s3_key
11
11
  attr_accessor :s3_secret
12
12
  attr_accessor :cache_manager
13
+ attr_accessor :skip_direct_upload
13
14
 
14
15
  def self.instance(opts={})
15
16
  return @instance || @instance = self.new(opts)
@@ -24,6 +25,7 @@ module Shutterbug
24
25
  self.s3_key = opts[:s3_key]
25
26
  self.s3_secret = opts[:s3_secret]
26
27
  self.cache_manager = opts[:cache_manager] || Shutterbug::CacheManager::NoCache.new
28
+ self.skip_direct_upload = opts[:skip_direct_upload]
27
29
  end
28
30
 
29
31
  def fs_path_for(filename)
@@ -6,6 +6,12 @@ module Shutterbug
6
6
  module Handlers
7
7
  class DirectUploadHandler
8
8
 
9
+ def skip_direct_upload
10
+ return true if Configuration.instance.skip_direct_upload
11
+ return true unless Configuration.instance.use_s3?
12
+ return false
13
+ end
14
+
9
15
  def self.regex
10
16
  /#{Configuration.instance.path_prefix}\/img_upload_url/
11
17
  end
@@ -13,17 +19,24 @@ module Shutterbug
13
19
  # Returns put_url and get_url for a new file that should be uploaded by the client.
14
20
  # Of course get_url will work after file is uploaded.
15
21
  def handle(helper, req, env)
16
- format = req.GET()['format'] || 'png'
17
-
18
- object_name = "img-#{SecureRandom.uuid}.#{format}"
19
- storage = Configuration.instance.storage
20
- unless storage.respond_to? :put_url
21
- return helper.response('direct upload not available', 'text/plain', 400)
22
+ if skip_direct_upload
23
+ not_available_response(helper)
24
+ else
25
+ format = req.GET()['format'] || 'png'
26
+ object_name = "img-#{SecureRandom.uuid}.#{format}"
27
+ storage = Configuration.instance.storage
28
+ unless storage.respond_to? :put_url
29
+ not_available_response(helper)
30
+ end
31
+ helper.response({
32
+ put_url: storage.put_url(object_name),
33
+ get_url: storage.get_url(object_name),
34
+ }.to_json, 'application/json')
22
35
  end
23
- helper.response({
24
- put_url: storage.put_url(object_name),
25
- get_url: storage.get_url(object_name),
26
- }.to_json, 'application/json')
36
+ end
37
+
38
+ def not_available_response(helper)
39
+ return helper.response('direct upload not available', 'text/plain', 400)
27
40
  end
28
41
  end
29
42
  end
data/shutterbug.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'shutterbug'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "shutterbug"
8
8
  spec.version = Shutterbug::VERSION
9
- spec.authors = ["Noah Paessel"]
10
- spec.email = ["knowuh@gmail.com"]
9
+ spec.authors = ["Noah Paessel", "Piotr Janik"]
10
+ spec.email = ["knowuh@gmail.com","janikpiotrek@gmail.com"]
11
11
 
12
12
  spec.description = %q{
13
13
  A rack utility that will create and save images (pngs)
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shutterbug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Paessel
8
+ - Piotr Janik
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
12
+ date: 2014-12-12 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -142,6 +143,7 @@ description: ! "\n A rack utility that will create and save images (pngs)\n
142
143
  SVG and Canvas elements.\n "
143
144
  email:
144
145
  - knowuh@gmail.com
146
+ - janikpiotrek@gmail.com
145
147
  executables: []
146
148
  extensions: []
147
149
  extra_rdoc_files: []