def download(target = Dir.mktmpdir, options = {})
      target = File.expand_path(target)

      # Make the directory if it doesn't yet exist
      FileUtils.mkdir_p(target) unless File.exist?(target)

      # Use the server artifact's filename if one wasn't given
      filename = options[:filename] || File.basename(download_uri)

      # Construct the full path for the file
      destination = File.join(target, filename)

      File.open(destination, "wb") do |file|
        client.get(download_uri) do |chunk|
          file.write chunk
        end
      end

      destination
    end
def download(target = Dir.mktmpdir, options = {})
      target = File.expand_path(target)

      # Make the directory if it doesn't yet exist
      FileUtils.mkdir_p(target) unless File.exist?(target)

      # Use the server artifact's filename if one wasn't given
      filename = options[:filename] || File.basename(download_uri)

      # Construct the full path for the file
      destination = File.join(target, filename)

      File.open(destination, "wb") do |file|
        client.get(download_uri) do |chunk|
          file.write chunk
        end
      end

      destination
    end
Download the artifact onto the local disk.

 @example Download an artifact
   artifact.download #=> /tmp/cache/000adad0-bac/artifact.deb

 @example Download a remote artifact into a specific target
   artifact.download('~/Desktop') #=> ~/Desktop/artifact.deb

 @param [String] target
   the target directory where the artifact should be downloaded to
   (defaults to a temporary directory). **It is the user's responsibility
   to cleanup the temporary directory when finished!**
 @param [Hash] options
 @option options [String] filename
   the name of the file when downloaded to disk (defaults to the basename
   of the file on the server)

 @return [String]
   the path where the file was downloaded on disk