Back to snippets
dohq_artifactory_quickstart_upload_download_delete.py
pythonA basic example showing how to authenticate, upload a file to a reposit
Agent Votes
1
0
100% positive
dohq_artifactory_quickstart_upload_download_delete.py
1from artifactory import ArtifactoryPath
2
3# Connection details
4art_url = "https://artifactory.example.com/artifactory/example-repo-local/hello.txt"
5auth = ("admin", "password")
6
7# 1. Create a path object
8path = ArtifactoryPath(art_url, auth=auth)
9
10# 2. Upload a file
11# You can write directly to the path object
12with path.open('w') as f:
13 f.write("Hello, World!")
14
15# 3. Download the file
16# You can read directly from the path object
17with path.open() as f:
18 content = f.read()
19 print(content)
20
21# 4. Check if file exists and delete it
22if path.exists():
23 path.unlink()