module Blobsterix::S3UrlHelper

Constants

HOST_PATH

Public Instance Methods

bucket() click to toggle source
# File lib/blobsterix/s3/s3_url_helper.rb, line 33
def bucket
  return env['HTTP_X_AMZ_BUCKET'] if env['HTTP_X_AMZ_BUCKET']
  host = bucket_matcher(env['HTTP_HOST'])
  if host
    host[1]
  elsif  (env[nil] && env[nil][:bucket])
    env[nil][:bucket]
  elsif  (env[nil] && env[nil][:bucket_or_file])
    if env[nil][:bucket_or_file].include?("/")
      env[nil][:bucket_or_file].split("/")[0]
    else
      env[nil][:bucket_or_file]
    end
  else
    "root"
  end
end
bucket?() click to toggle source
# File lib/blobsterix/s3/s3_url_helper.rb, line 51
def bucket?
  host = bucket_matcher(env['HTTP_HOST'])
  host || env[nil][:bucket] || included_bucket || env['HTTP_X_AMZ_BUCKET']
end
bucket_matcher(str) click to toggle source
# File lib/blobsterix/s3/s3_url_helper.rb, line 4
def bucket_matcher(str)
  if str.include?("s3")
    str.match(/(\w+)\.s3\.\w+\.\w+/)
  else
    str.match(/(\w+)\.\w+\.\w+/)
  end
end
cache_upload() click to toggle source
# File lib/blobsterix/s3/s3_url_helper.rb, line 12
def cache_upload
  cache.put_stream(cache_upload_key, env['rack.input'])
end
cache_upload_key() click to toggle source
# File lib/blobsterix/s3/s3_url_helper.rb, line 25
def cache_upload_key
  @cache_upload_key ||= Blobsterix::BlobAccess.new(:bucket => bucket, :id => "upload_#{file.gsub("/", "_")}")
end
cached_upload() click to toggle source
# File lib/blobsterix/s3/s3_url_helper.rb, line 16
def cached_upload
  cache_upload if not cache.exists?(cache_upload_key)
  cache.get(cache_upload_key)
end
cached_upload_clear() click to toggle source
# File lib/blobsterix/s3/s3_url_helper.rb, line 21
def cached_upload_clear
  cache.delete(cache_upload_key)
end
transformation_string() click to toggle source
# File lib/blobsterix/s3/s3_url_helper.rb, line 29
def transformation_string
  @trafo ||= env["HTTP_X_AMZ_META_TRAFO"] || ""
end