How to request size of the artifact from Nexus repository?

三世轮回 提交于 2021-01-27 07:09:13

问题


I know Nexus support REST request. Would you please tell me how to request from repository based on Nexus the size of certain artifact?

Thank you.


回答1:


You have the following option: Use the full path to the artifact content URI and add the parameter describe=info

For example:

https://repository.sonatype.org/service/local/repositories/maven-sites/content/nexus-oss/css/maven-theme.css?describe=info

Returns an ArtifactInfoResourceResponse, which is an XML that contains the artifact size in KB:

<org.sonatype.nexus.rest.model.ArtifactInfoResourceResponse>
  <data>
    <presentLocally>true</presentLocally>
    <repositoryId>maven-sites</repositoryId>
    <repositoryName>maven-sites</repositoryName>
    <repositoryPath>/nexus-oss/css/maven-theme.css</repositoryPath>
    <mimeType>text/css</mimeType>
    <uploader>grid</uploader>
    <uploaded>1324414832000</uploaded>
    <lastChanged>1324414832000</lastChanged>
    <size>2801</size>
    <sha1Hash>f773e0309d4c0f7aab4aac0ec3ae50088ad02394</sha1Hash>
    <md5Hash>61d12a98b59a0fefcc3b0ed8313239de</md5Hash>
    <repositories>
      <org.sonatype.nexus.rest.model.RepositoryUrlResource>
        <repositoryId>maven-sites</repositoryId>
        <repositoryName>maven-sites</repositoryName>
        <path>/nexus-oss/css/maven-theme.css</path>
        <artifactUrl>https://repository.sonatype.org/content/repositories/maven-sites/nexus-oss/css/maven-theme.css</artifactUrl>
        <canView>true</canView>
      </org.sonatype.nexus.rest.model.RepositoryUrlResource>
    </repositories>
    <canDelete>false</canDelete>
  </data>
</org.sonatype.nexus.rest.model.ArtifactInfoResourceResponse>


来源:https://stackoverflow.com/questions/17475049/how-to-request-size-of-the-artifact-from-nexus-repository

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!