remote_files 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7bdd6a2996936339581664a79c8258c779f3b8f5
4
- data.tar.gz: 71736655623982c8fa949a8a3b4a9b0ac8ecf151
3
+ metadata.gz: 6c8ead4405ea92b13e52d80245f39fc8c9b8a92c
4
+ data.tar.gz: 39be4dfe16249c81ff02a2528ecbefec05213745
5
5
  SHA512:
6
- metadata.gz: a5fa60188f842e9f88acee6708dd2e445e93a1fd1529d29137c3d229b0ce7a41e4b178d437074e842c94e90408022fbb932f3a031b38aae317c61f659dd15126
7
- data.tar.gz: e98f60b4c50a47a7173f7de996708d29bba301ba881950a06f30930268a7ab9f891090b1be50a4b483d36bb61990bf73e8e01c7e308377efd4679fb02fad3230
6
+ metadata.gz: 179f4a4d9040eb4850d187dedb96d4c041ad99b611749a1d345e959ca5449be1ad0615e78e6a4e2c3310f0632ba694d4fc72da1e492c9c344b6edecc1b5086cb
7
+ data.tar.gz: 238967288e3e006be0794ac089fdd46381c40f7c8cdeb3aca0ab294c5c731adee4ca9e3d200076dc5aec84617f574375e2bffafdfc75c5141008814db6cb6c00
@@ -2,14 +2,11 @@ require 'fog'
2
2
 
3
3
  module RemoteFiles
4
4
  class FogStore < AbstractStore
5
+ MULTIPART_MAX_PARTS = 10000
6
+ MULTIPART_MIN_SIZE = 5 * 1024 * 1024
7
+
5
8
  def store!(file)
6
- success = directory.files.create(
7
- :body => file.content,
8
- :content_type => file.content_type,
9
- :key => file.identifier,
10
- :public => options[:public],
11
- :encryption => options[:encryption]
12
- )
9
+ success = directory.files.create(store_options(file))
13
10
 
14
11
  raise RemoteFiles::Error unless success
15
12
 
@@ -98,5 +95,29 @@ module RemoteFiles
98
95
  dir.save
99
96
  end
100
97
  end
98
+
99
+ def store_options(file)
100
+ store_options =
101
+ {
102
+ :body => file.content,
103
+ :content_type => file.content_type,
104
+ :key => file.identifier,
105
+ :public => options[:public],
106
+ :encryption => options[:encryption]
107
+ }
108
+ if file.options[:multipart_chunk_size]
109
+ raise RemoteFiles::Error.new("Only S3 supports the multipart_chunk_size option") unless options[:provider] == 'AWS'
110
+ chunk_size = file.options[:multipart_chunk_size]
111
+ store_options[:multipart_chunk_size] = chunk_size
112
+ raise RemoteFiles::Error.new("Minimum chunk size is #{MULTIPART_MIN_SIZE}") if chunk_size < MULTIPART_MIN_SIZE
113
+ if !file.content.respond_to?(:read) || !file.content.respond_to?(:size)
114
+ raise RemoteFiles::Error.new(':content must be a stream if chunking enabled')
115
+ end
116
+ if file.content.size / chunk_size > MULTIPART_MAX_PARTS
117
+ raise RemoteFiles::Error.new("Increase chunk size so that there are less then #{10000}{MULTIPART_MAX_PARTS} parts")
118
+ end
119
+ end
120
+ store_options
121
+ end
101
122
  end
102
123
  end
@@ -1,3 +1,3 @@
1
1
  module RemoteFiles
2
- VERSION = '2.2.1'
2
+ VERSION = '2.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_files
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-02 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
@@ -63,11 +63,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  version: '0'
64
64
  requirements: []
65
65
  rubyforge_project:
66
- rubygems_version: 2.2.2
66
+ rubygems_version: 2.4.7
67
67
  signing_key:
68
68
  specification_version: 4
69
69
  summary: The purpose of the library is to implement a simple interface for uploading
70
70
  files to multiple backends and to keep the backends in sync, so that your app will
71
71
  keep working when one backend is down.
72
72
  test_files: []
73
- has_rdoc: