diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index d2f2a42893e9e2b1b15d9b7ffca7c30dc8a7d669..6e8dcdefe578b5497710e147b98ec77a04726b90 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -161,15 +161,18 @@ setup_deploy() {
 
 
 # Uploads a file to our intranet location via curl
+# $1: Path to the file to upload (e.g. dist/myfile.whl)
+# $2: Path on the server to upload to (e.g. wheels-upload/gitlab/)
 doc_upload() {
   log_info "curl: ${1} -> ${DOCSERVER}/${2}..."
-  curl --location --silent --show-error --user "${DOCUSER}:${DOCPASS}" --upload-file ${1} ${DOCSERVER}/${2}
-  local status=$?
-  if [ ${status} != 0 ]; then
-    log_error "Curl command finished with an error condition (status=${status})"
+  local code=`curl --location --silent --fail --write-out "%{http_code}" --user "${DOCUSER}:${DOCPASS}" --upload-file ${1} ${DOCSERVER}/${2}`
+  if [[ ${code} == 204 || ${code} == 201 ]]; then
+    log_info "Successfully uploaded ${1} with curl"
+  else
+    log_error "Curl command finished with an error condition (code=${code}):"
+    curl --location --silent --user "${DOCUSER}:${DOCPASS}" --upload-file ${1} ${DOCSERVER}/${2}
     exit ${status}
   fi
-  log_info "Successfully uploaded ${1} with curl"
 }