* notes
This commit is contained in:
parent
bb9beb9cab
commit
b884ef3296
|
|
@ -1,5 +1,6 @@
|
|||
module JamRuby
|
||||
class ArtifactUpdate < ActiveRecord::Base
|
||||
include JamRuby::S3ManagerMixin
|
||||
|
||||
DEFAULT_ENVIRONMENT = 'public'
|
||||
CLIENT_PREFIX = 'JamClient'
|
||||
|
|
@ -50,5 +51,15 @@ module JamRuby
|
|||
|
||||
url
|
||||
end
|
||||
|
||||
# generate a secure URL for a hidden/private S3 artifact
|
||||
def secure_url
|
||||
|
||||
self.version
|
||||
self.product
|
||||
#self[:uri]
|
||||
|
||||
s3_manager.sign_url(self[:uri], {:expires => 60 * 5 , :secure => true})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
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
|
||||
|
|
@ -194,6 +194,8 @@ SampleApp::Application.routes.draw do
|
|||
|
||||
scope '/api' do
|
||||
|
||||
match '/jamblaster' => 'api_jam_blaster#artifact', :via => :get
|
||||
|
||||
match '/auths/login' => 'api_auths#login', :via => :post
|
||||
|
||||
# music sessions
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ApiJamBlasterController do
|
||||
render_views
|
||||
|
||||
|
||||
# probably better to put as much logic (and meaningful tests) in artifact_update_spec
|
||||
it "works" do
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue