Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if file exists in artifactory without downloading

Tags:

artifactory

I need to check if a file exists. My approach until now was doing it via Artifactory REST API

url = https://artifactory.io/path_to_file/file.jar
headers = {'X-JFrog-Art-Api': 'api_key'}
response = requests.get(url, headers=headers)
assert(200 == response.status_code)
assert(response.text != "")

but there's a file that it too big and it's taking too long to get the response.

Is there another way to check if this file exists?

like image 220
Manuel Mena Avatar asked Sep 03 '25 14:09

Manuel Mena


2 Answers

You could check the status code returned when getting the file info, not the file itself.

See the documentation of this REST API.

For example:

url = https://artifactory.io/api/storage/path_to_file/file.jar

headers = {'X-JFrog-Art-Api': 'api_key'}
response = requests.get(url, headers=headers)
assert(200 == response.status_code)
assert(response.text != "")
like image 50
Prostagma Avatar answered Sep 05 '25 16:09

Prostagma


You can use one of the Search APIs or (and that is what I recommend) use the JFrog CLI search commands

like image 26
Ortsigat Avatar answered Sep 05 '25 15:09

Ortsigat