# File lib/chef/knife/cookbook_site_share.rb, line 78
      def do_upload(cookbook_filename, cookbook_category, user_id, user_secret_filename)
         uri = "http://cookbooks.opscode.com/api/v1/cookbooks"

         category_string = { 'category'=>cookbook_category }.to_json

         http_resp = Chef::CookbookSiteStreamingUploader.post(uri, user_id, user_secret_filename, {
           :tarball => File.open(cookbook_filename),
           :cookbook => category_string
         })

         res = JSON.parse(http_resp.body)
         if http_resp.code.to_i != 201
           if res['error_messages']
             if res['error_messages'][0] =~ /Version already exists/
               Chef::Log.error "The same version of this cookbook already exists on the Opscode Cookbook Site."
               exit(1)
             else
               Chef::Log.error "#{res['error_messages'][0]}"
               exit(1)
             end
           else
             Chef::Log.error "Unknown error while sharing cookbook"
             Chef::Log.error "Server response: #{http_resp.body}"
             exit(1)
           end
         end
         res
       end