Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- artifactory_url = 'artifactory.com' # your artifactory instance
- artifactory_username = 'username' # your username
- artifcatory_password = 'password' # your password
- content_type = 'application/java-archive' # your content-type header
- filename = 'file' # your file to upload (in current working directory)
- url = artifactory_url + '/' + filename # where we want the file stored on artifactory
- # checksums are useful for making sure the upload was successful
- headers = {'content-type': content_type,
- 'X-Checksum-Md5': hashlib.md5(open(filename).read()).hexdigest(),
- 'X-Checksum-Sha1': hashlib.sha1(open(filename).read()).hexdigest()}
- with open(filename, 'rb') as f:
- r = requests.put(url,
- auth=(artifactory_username,
- artifactory_password),
- data=f,
- headers=headers)
- # check for success
- if r.status_code != 201:
- print "Something went wrong"
- else:
- print r.json()['downloadUri'] # download url for this new artifact
Add Comment
Please, Sign In to add comment