public Path downloadMpack(String mpackURI, String mpackDefinitionLocation) throws IOException {

    File stagingDir = new File(mpackStaging.toString() + File.separator + MPACK_TAR_LOCATION);
    Path targetPath = new File(stagingDir.getPath() + File.separator + mpackDefinitionLocation).toPath();
    String mpackTarURI = mpackURI.substring(0, mpackURI.lastIndexOf('/')) + File.separator + mpackDefinitionLocation;
    URL url = new URL(mpackTarURI);

    if (!stagingDir.exists()) {
      stagingDir.mkdirs();
    }

    Files.copy(url.openStream(), targetPath, StandardCopyOption.REPLACE_EXISTING);

    return targetPath;
  }
Download the mpack from the given uri

@param mpackURI
@param mpackDefinitionLocation
@return
ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java