require 'scrivito/cms_backend' module Scrivito class CmsBackend # prevent the use of local URLs (localhost:7104) from cache # when running under a server def find_blob_data_from_cache(id, access, verb, transformation_definition) cache_key = blob_data_cache_key(normalize_blob_id(id), access, verb, transformation_definition) data = CmsDataCache.cache.read(cache_key) if !data.nil? && Fiona7::Middleware::ServerDetectionMiddleware.server_detected? tainted_data = data['url'] =~ /\Ahttps?:\/\/localhost:7104/ if tainted_data nil else data end else data end end # prevent real get requests since we run everything locally # def request_blob_metadata_from_s3(url) # @query_counter += 1 # blob_id = /\/_b\/([0-9]+)/.match(url)[1] # raise ScrivitoError, "Unexpected 's3' url: #{url}" unless blob_id.present? # rest_api_meta_data = Fiona7::Controllers::RestAPI::BlobController.new.metadata(blob_id) # meta_data = {} # meta_data[:content_type] = rest_api_meta_data['meta_data']['content_type'].last # meta_data[:content_length] = rest_api_meta_data['meta_data']['content_length'].last # meta_data[:cache_control] = 'no-transform,public,max-age=300,s-maxage=900' # meta_data # end end end