Search code examples
artifactory

How to specify putting zip into jfrog artifactory?


I have directory like /tmp/some-js/(a lot of folders)

I added it into zip /tmp/some-js.zip

I have structure in artifactory like /npm-dev/some-js/*

I put into artifactory this zip with command

curl -u user:api-key -k -X PUT https://xxx.xx.xx.xx:8081/artifactory/npm_dev/some-js/ -T /tmp/some-js.zip

And I have got directory in artifactory /npm-dev/some-js/some-js.zip/*

There is a way to specify unpacking some-js.zip contents into /npm-dev/some-js ?


Solution

  • Uploading an archive file (such as a zip file) to Artifactory and extracting its content to a specific directory is done by:

    PUT https://<jfrog-platform>/artifactory/the-repo/path/to/dir/file.zip
    X-Explode-Archive: true
    
    <file-content>
    

    The content of file.zip will be extracted and deployed under the-repo/path/to/dir/, preserving the relative directory structure in the zip file. So if file.zip has the following structure:

    foo/
      |- bar.txt
      |- baz.txt
    

    The following files will be created in Artifactory:

    the-repo/path/to/dir/foo/bar.txt
    the-repo/path/to/dir/foo/baz.txt
    

    Using curl and the details in the question:

    curl -u user:api-key \
         -k \
         -X PUT \
         https://xxx.xx.xx.xx:8081/artifactory/npm_dev/some-js/some-js.zip \
         -T /tmp/some-js.zip
         -H "X-Explode-Archive: true"
    

    For more information, see the documentation on Deploy Artifacts from Archive