def import_scan(site_id, zip_file)
      data = Rexlite::MIME::Message.new
      data.add_part(site_id.to_s, nil, nil, 'form-data; name="siteid"')
      data.add_part(session_id, nil, nil, 'form-data; name="nexposeCCSessionID"')
      ::File.open(zip_file, 'rb') do |scan|
        data.add_part(scan.read, 'application/zip', 'binary',
                      "form-data; name=\"scan\"; filename=\"#{zip_file}\"")
      end

      post = Net::HTTP::Post.new('/data/scan/import')
      post.body = data.to_s
      post.set_content_type('multipart/form-data', boundary: data.bound)

      # Avoiding AJAX#request, because the data can cause binary dump on error.
      http = AJAX.https(self)
      AJAX.headers(self, post)
      response = http.request(post)
      case response
      when Net::HTTPOK
        response.body.empty? ? response.body : response.body.to_i
      when Net::HTTPUnauthorized
        raise Nexpose::PermissionError.new(response)
      else
        raise Nexpose::APIError.new(post, response.body)
      end
    end
def import_scan(site_id, zip_file)
      data = Rexlite::MIME::Message.new
      data.add_part(site_id.to_s, nil, nil, 'form-data; name="siteid"')
      data.add_part(session_id, nil, nil, 'form-data; name="nexposeCCSessionID"')
      ::File.open(zip_file, 'rb') do |scan|
        data.add_part(scan.read, 'application/zip', 'binary',
                      "form-data; name=\"scan\"; filename=\"#{zip_file}\"")
      end

      post = Net::HTTP::Post.new('/data/scan/import')
      post.body = data.to_s
      post.set_content_type('multipart/form-data', boundary: data.bound)

      # Avoiding AJAX#request, because the data can cause binary dump on error.
      http = AJAX.https(self)
      AJAX.headers(self, post)
      response = http.request(post)
      case response
      when Net::HTTPOK
        response.body.empty? ? response.body : response.body.to_i
      when Net::HTTPUnauthorized
        raise Nexpose::PermissionError.new(response)
      else
        raise Nexpose::APIError.new(post, response.body)
      end
    end
Import scan data into a site.

 This method is designed to work with export_scan to migrate scan data
 from one console to another. This method will import the data as if run
 from a local scan engine.

 Scan importing is restricted to only importing scans in chronological
 order. It assumes that it is the latest scan for a given site, and will
 abort if attempting to import an older scan.

 @param [Fixnum] site_id Site ID of the site to import the scan into.
 @param [String] zip_file Path to a previously exported scan archive.
 @return [Fixnum] The scan ID on success.