如何使用REST从apache archiva中以编程方式下载单个工件? [英] How do I download programmatically a single artifact from apache archiva using REST?

查看:155
本文介绍了如何使用REST从apache archiva中以编程方式下载单个工件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仔细阅读了文档,发现了很多有用的东西.我目前正在使用Apache Archiva作为镜子.使用maven下载工件可以正常工作,但是出于某些原因,我希望能够使用REST api下载工件.

I went through the documentation and found many useful things. I am currently using apache archiva as a mirror. Downloading the artifacts with maven works fine but I would like to be able to download the artifact using REST api for certain reasons.

目前,我可以使用指向工件下载URL的直接URL来完成此操作,但这似乎不是一个好方法.

For now I can do it by using a direct url to the artifact's download URL which does not seem to be a good way of doing it.

我错过了任何可以让我做以下服务器的休息服务吗:port/restServices/getArtifact/groupId/artifactId/version

Is there any rest service I missed which would allow me to do the following server:port/restServices/getArtifact/groupId/artifactId/version

推荐答案

REST调用是:

GET http://server/restServices/archivaServices/browseService/artifactDownloadInfos/{group}/{artifact}/{version}

响应包含条目列表,其"URL"键是下载工件的链接.每个可下载资源都有一个条目,例如一个用于jar,另一个用于pom,等等."type"键可用于分辨哪个.

The response contains a list of entries whose 'url' key is the link to download the artifact. There's an entry for each downloadable resource, e.g. one for jar, another for pom, etc. The 'type' key can be used to tell which.

示例响应:

[
      {
      "context": "internal",
      "url": "http://server/repository/internal/group/artifact/version/artifact-version.jar",
      "groupId": "group",
      "artifactId": "obs.interfaces",
      "repositoryId": "internal",
      "version": "version",
      "prefix": null,
      "goals": null,
      "bundleVersion": null,
      "bundleSymbolicName": null,
      "bundleExportPackage": null,
      "bundleExportService": null,
      "bundleDescription": null,
      "bundleName": null,
      "bundleLicense": null,
      "bundleDocUrl": null,
      "bundleImportPackage": null,
      "bundleRequireBundle": null,
      "classifier": null,
      "packaging": "jar",
      "fileExtension": "jar",
      "size": "31.78 K",
      "type": "jar",
      "path": "group/artifact/version/artifact-version.jar",
      "id": "artifact-version.jar",
      "scope": null
   },
      {
      "context": "internal",
      "url": "http://server/repository/internal/group/artifact/version/artifact-version.pom",
      "groupId": "group",
      "artifactId": "artifact",
      "repositoryId": "internal",
      "version": "version",
      "prefix": null,
      "goals": null,
      "bundleVersion": null,
      "bundleSymbolicName": null,
      "bundleExportPackage": null,
      "bundleExportService": null,
      "bundleDescription": null,
      "bundleName": null,
      "bundleLicense": null,
      "bundleDocUrl": null,
      "bundleImportPackage": null,
      "bundleRequireBundle": null,
      "classifier": null,
      "packaging": "pom",
      "fileExtension": "pom",
      "size": "1.58 K",
      "type": "pom",
      "path": "group/artifact/version/artifact-version.pom",
      "id": "artifact-version.pom",
      "scope": null
   }
]

享受!

这篇关于如何使用REST从apache archiva中以编程方式下载单个工件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆