Module: Fog::AWS::Storage::Utils
Instance Attribute Summary collapse
-
#disable_content_md5_validation ⇒ Object
Returns the value of attribute disable_content_md5_validation.
-
#max_copy_chunk_size ⇒ Object
readonly
Returns the value of attribute max_copy_chunk_size.
-
#max_put_chunk_size ⇒ Integer
readonly
Amazon S3 limits max chunk size that can be uploaded/copied in a single request to 5GB.
-
#region ⇒ Object
Returns the value of attribute region.
Instance Method Summary collapse
- #cdn ⇒ Object
- #http_url(params, expires) ⇒ Object
- #https_url(params, expires) ⇒ Object
- #request_url(params) ⇒ Object
- #require_mime_types ⇒ Object
- #signed_url(params, expires) ⇒ Object
- #url(params, expires) ⇒ Object
- #validate_chunk_size(value, description) ⇒ Object
Instance Attribute Details
#disable_content_md5_validation ⇒ Object
Returns the value of attribute disable_content_md5_validation.
160 161 162 |
# File 'lib/fog/aws/storage.rb', line 160 def disable_content_md5_validation @disable_content_md5_validation end |
#max_copy_chunk_size ⇒ Object (readonly)
Returns the value of attribute max_copy_chunk_size.
171 172 173 |
# File 'lib/fog/aws/storage.rb', line 171 def max_copy_chunk_size @max_copy_chunk_size end |
#max_put_chunk_size ⇒ Integer (readonly)
Amazon S3 limits max chunk size that can be uploaded/copied in a single request to 5GB. Other S3-compatible storages (like, Ceph) do not have such limit. Ceph shows much better performance when file is copied as a whole, in a single request. fog-aws user can use these settings to configure chunk sizes. A non-positive value will tell fog-aws to use a single put/copy request regardless of file size.
170 171 172 |
# File 'lib/fog/aws/storage.rb', line 170 def max_put_chunk_size @max_put_chunk_size end |
#region ⇒ Object
Returns the value of attribute region.
159 160 161 |
# File 'lib/fog/aws/storage.rb', line 159 def region @region end |
Instance Method Details
#cdn ⇒ Object
173 174 175 176 177 178 179 180 |
# File 'lib/fog/aws/storage.rb', line 173 def cdn credentials = @credentials @cdn ||= Fog::AWS::CDN.new( :aws_access_key_id => credentials.aws_access_key_id, :aws_secret_access_key => credentials.aws_secret_access_key, :use_iam_profile => @use_iam_profile ) end |
#http_url(params, expires) ⇒ Object
182 183 184 |
# File 'lib/fog/aws/storage.rb', line 182 def http_url(params, expires) signed_url(params.merge(:scheme => 'http'), expires) end |
#https_url(params, expires) ⇒ Object
186 187 188 |
# File 'lib/fog/aws/storage.rb', line 186 def https_url(params, expires) signed_url(params.merge(:scheme => 'https'), expires) end |
#request_url(params) ⇒ Object
209 210 211 212 |
# File 'lib/fog/aws/storage.rb', line 209 def request_url(params) params = request_params(params) params_to_url(params) end |
#require_mime_types ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/fog/aws/storage.rb', line 195 def require_mime_types begin # Use mime/types/columnar if available, for reduced memory usage require 'mime/types/columnar' rescue LoadError begin require 'mime/types' rescue LoadError Fog::Logger.warning("'mime-types' missing, please install and try again.") exit(1) end end end |
#signed_url(params, expires) ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/fog/aws/storage.rb', line 214 def signed_url(params, expires) refresh_credentials_if_expired #convert expires from a point in time to a delta to now expires = expires.to_i if @signature_version == 4 params = v4_signed_params_for_url(params, expires) else params = v2_signed_params_for_url(params, expires) end params_to_url(params) end |
#url(params, expires) ⇒ Object
190 191 192 193 |
# File 'lib/fog/aws/storage.rb', line 190 def url(params, expires) Fog::Logger.deprecation("Fog::AWS::Storage => #url is deprecated, use #https_url instead [light_black](#{caller.first})[/]") https_url(params, expires) end |
#validate_chunk_size(value, description) ⇒ Object
230 231 232 |
# File 'lib/fog/aws/storage.rb', line 230 def validate_chunk_size(value, description) raise "#{description} (#{value}) is less than minimum #{MIN_MULTIPART_CHUNK_SIZE}" unless value <= 0 || value >= MIN_MULTIPART_CHUNK_SIZE end |