Artifactory upload with checksum

spuder picture spuder · Oct 13, 2016 · Viewed 10.5k times · Source

If you upload an artifact to Artifactory and don't provide a checksum, it gives this warning:

Screenshot, Artifactory, Fix Checksum

How do you upload with curl and include a checksum?

Answer

spuder picture spuder · Oct 13, 2016

This feature currently isn't well documented, an example is found on this page:

https://www.jfrog.com/knowledge-base/what-are-client-checksum-server-checksum-and-checksum-policy-in-local-repositories/

Simply add the following to the curl command: "--header "X-Checksum-<type>:${CHECKSUM}"

Sha1

CHECKSUM=$(shasum -a 1 foo.zip | awk '{ print $1 }')

curl --header "X-Checksum-Sha1:${CHECKSUM}" --upload-file "foo.zip -u "admin:<apikey>" -v https://artifactory.example.com/foo/

MD5

CHECKSUM=$(md5sum foo.zip | awk '{ print $1 }')

curl --header "X-Checksum-MD5:${CHECKSUM}" --upload-file "foo.zip -u "admin:<apikey>" -v https://artifactory.example.com/foo/

Or provide both checksums at once

ARTIFACT_MD5_CHECKSUM=$(md5sum foo.zip | awk '{print $1}')
ARTIFACT_SHA1_CHECKSUM=$(shasum -a 1 foo.zip | awk '{ print $1 }')
curl --upload-file "foo.zip" \
--header "X-Checksum-MD5:${ARTIFACT_MD5_CHECKSUM}" \
--header "X-Checksum-Sha1:${ARTIFACT_SHA1_CHECKSUM}" \
-u "admin:<apikey>" \
-v https://artifactory.example.com/foo/

Unfortunatley, uploading with the sha256 doesn't work with curl because of a bug