lib/cloud_crowd/action.rb in documentcloud-cloud-crowd-0.1.0 vs lib/cloud_crowd/action.rb in documentcloud-cloud-crowd-0.1.1

- old
+ new

@@ -36,16 +36,20 @@ raise NotImplementedError.new("CloudCrowd::Actions must override 'process' with their own processing code.") end # Download a file to the specified path. def download(url, path) - if url.match(FILE_URL) - FileUtils.cp(url.sub(FILE_URL, ''), path) - else - resp = RestClient::Request.execute(:url => url, :method => :get, :raw_response => true) - FileUtils.mv resp.file.path, path - end + URI.parse(url) # Sanity check. + `curl -s "#{url}" > "#{path}"` + # if url.match(FILE_URL) + # FileUtils.cp(url.sub(FILE_URL, ''), path) + # else + # # An alternative would be shelling out: `curl -s "#{url}" > "#{path}"` + # puts url + # resp = RestClient::Request.execute(:url => url, :method => :get, :raw_response => true) + # FileUtils.mv resp.file.path, path + # end path end # Takes a local filesystem path, saves the file to S3, and returns the # public (or authenticated) url on S3 where the file can be accessed. @@ -53,10 +57,10 @@ save_path = File.join(storage_prefix, File.basename(file_path)) @store.save(file_path, save_path) end # After the Action has finished, we remove the work directory and return - # to the root directory (where daemons run by default). + # to the root directory (where workers run by default). def cleanup_work_directory FileUtils.rm_r(@work_directory) if File.exists?(@work_directory) end \ No newline at end of file