我是靠谱客的博主 勤恳枕头,最近开发中收集的这篇文章主要介绍Artifactory 上传和下载Artifactory 上传和下载,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Artifactory 上传和下载

主要提供python和java对私服Artifactory使用用户和密码或者oken上传和下载功能,

python版本

版本artifactory==0.1.17

from artifactory import ArtifactoryPath
import tarfile

username = "demo"
password = "demo"
token = "eyJ2ZXIiOi"


# Download Artifacts
def download(download_url):
    download_path = ArtifactoryPath(download_url, auth=(username, password))
    # download_path = ArtifactoryPath(download_url, auth=(username, token))
    with download_path.open() as fd:
        with open(r"D:downloadtest-tensorflow-gpu.tar", "wb") as out:
            out.write(fd.read())


# Update Artifacts
def upload(upload_url):
    upload_path = ArtifactoryPath(upload_url, auth=(username, password))
    if not upload_path.exists():
        upload_path.mkdir()
    upload_path.deploy_file(r"D:tensorflow-gpu-1.12.0.tar")


if __name__ == '__main__':
    download_url = "http://ip:port/artifactory/test/tensorflow-gpu-1.12.0.tar"
    download(download_url)

    upload_url = "http://ip:port/artifactory/test"
    upload(upload_url)

java版本

版本

        <dependency>
            <groupId>org.jfrog.artifactory.client</groupId>
            <artifactId>artifactory-java-client-services</artifactId>
            <version>2.8.3</version>
        </dependency>

基于Token认证下载代码

        try {
                Artifactory build = ArtifactoryClientBuilder.create().setUrl(host).setAccessToken(token).build();
                InputStream inputStream = build.repository(repoName).download(path).doDownload();
                entity.setInputStream(inputStream);
            } catch (Exception e) {
                LOG.error("下载失败", e);
            }

  • host:私服地址
  • token:身份令牌
  • repoName: 私服库名
  • path:相对路径

最后

以上就是勤恳枕头为你收集整理的Artifactory 上传和下载Artifactory 上传和下载的全部内容,希望文章能够帮你解决Artifactory 上传和下载Artifactory 上传和下载所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(42)

评论列表共有 0 条评论

立即
投稿
返回
顶部