From 364c1cffd971e162e5884f32abe2061dba01ae63 Mon Sep 17 00:00:00 2001 From: Lance Date: Wed, 19 Jan 2011 14:36:14 -0500 Subject: [PATCH] Add file upload to Artifact API class for creation of new versions --- app/controllers/artifact_versions_controller.rb | 2 +- lib/steamcannon/api/artifact.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/artifact_versions_controller.rb b/app/controllers/artifact_versions_controller.rb index f7b47c9..d8ae064 100644 --- a/app/controllers/artifact_versions_controller.rb +++ b/app/controllers/artifact_versions_controller.rb @@ -46,7 +46,7 @@ def create respond_to do |format| if @artifact_version.save format.html { redirect_to(@artifact, :notice => 'Version was successfully created.') } - format.xml { render :xml => @artifact_version, :status => :created, :location => @artifact_version } + format.xml { redirect_to(artifact_url(@artifact), :status => :created) } else format.html { render :action => "new" } format.xml { render :xml => @artifact_version.errors, :status => :unprocessable_entity } diff --git a/lib/steamcannon/api/artifact.rb b/lib/steamcannon/api/artifact.rb index 7b7284f..f8c8e19 100644 --- a/lib/steamcannon/api/artifact.rb +++ b/lib/steamcannon/api/artifact.rb @@ -8,8 +8,8 @@ def versions end end - def create_version(data) - puts "This part isn't done yet - but when it is, we'll upload #{data}" + def create_version(artifact_file) + @connector.post(@data['artifact_versions'][0]['href'], "artifact_version[archive]"=>File.new(artifact_file, "rb")) end protected