Search code examples
restcurljfrog-cli

How to download the latest uploaded file using jFrog with Curl command?


I have set of files uploaded to the global repository. I need to download the latest uploaded file.. How can I do it by using jFrog? Which Curl command should I use?

Currently I am using curl -O https://***/artifactory/snapshots/***/***/***/***-SNAPSHOT/test.xml which downloads the file on the server, but this is useful when there is a specific name, but, I want to download the latest one.


Solution

  • You can use Artifactory's AQL to apply your search/delete filters.

    specifically, in your example you can use SORT and LIMIT to retrieve your latest artifact

    items.find ({
            "repo":"my-global-repo"
    }).sort({"$desc" : ["created"]}).limit(1)
    

    AQL can be use in REST as well as with JFrog's CLI. You can find more AQL examples here.

    I would also recommend trying out the Jfrog CLI, which also supports Sorting and Limiting without the need to use AQL, and might be easier to use. You can find CLI examples here