jam-cloud/web/app/controllers/api_jam_blaster_controller.rb

34 lines
793 B
Ruby

class ApiJamBlasterController < ApiController
def artifact
# JamBlasterArtifact -> table calleds jam_blaster_artifacts
# /api/jamblaster?product=jb&version=1.0.3
product = params[:product]
version = params[:version]
# example of signing a bucket 'object' in S3
# example of sticking in a row in database
# insert into artifact_updates (product, version, uri, sha1, environment, size) values ('blah', '1.1.1', 'nowhere/valid', 'abc', 'public', 1);
artifact = ArtifactUpdate.where(product: product).where(version: version).first
if artifact.nil?
logger.debug("oo! no artifact for #{product}")
render json: {reason: 'not found'}, status: 404
else
url = artifact.secure_url
render json: {url: url}
end
end
end