Module: Fog::AWS::Storage::Utils

Included in:
Mock, Real
Defined in:
lib/fog/aws/storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#disable_content_md5_validationObject

Returns the value of attribute disable_content_md5_validation.



127
128
129
# File 'lib/fog/aws/storage.rb', line 127

def disable_content_md5_validation
  @disable_content_md5_validation
end

#max_copy_chunk_sizeObject (readonly)

Returns the value of attribute max_copy_chunk_size.



138
139
140
# File 'lib/fog/aws/storage.rb', line 138

def max_copy_chunk_size
  @max_copy_chunk_size
end

#max_put_chunk_sizeInteger (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.



137
138
139
# File 'lib/fog/aws/storage.rb', line 137

def max_put_chunk_size
  @max_put_chunk_size
end

#regionObject

Returns the value of attribute region.



126
127
128
# File 'lib/fog/aws/storage.rb', line 126

def region
  @region
end

Instance Method Details

#cdnObject



140
141
142
143
144
145
146
# File 'lib/fog/aws/storage.rb', line 140

def cdn
  @cdn ||= Fog::AWS::CDN.new(
    :aws_access_key_id => @aws_access_key_id,
    :aws_secret_access_key => @aws_secret_access_key,
    :use_iam_profile => @use_iam_profile
  )
end

#http_url(params, expires) ⇒ Object



148
149
150
# File 'lib/fog/aws/storage.rb', line 148

def http_url(params, expires)
  signed_url(params.merge(:scheme => 'http'), expires)
end

#https_url(params, expires) ⇒ Object



152
153
154
# File 'lib/fog/aws/storage.rb', line 152

def https_url(params, expires)
  signed_url(params.merge(:scheme => 'https'), expires)
end

#request_url(params) ⇒ Object



175
176
177
178
# File 'lib/fog/aws/storage.rb', line 175

def request_url(params)
  params = request_params(params)
  params_to_url(params)
end

#require_mime_typesObject



161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/fog/aws/storage.rb', line 161

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



180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/fog/aws/storage.rb', line 180

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



156
157
158
159
# File 'lib/fog/aws/storage.rb', line 156

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

Parameters:

  • value (int)
  • description (str)


196
197
198
# File 'lib/fog/aws/storage.rb', line 196

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