Skip to content

Instantly share code, notes, and snippets.

@antonfisher
Created September 12, 2019 21:08
Show Gist options
  • Save antonfisher/d6de3ae8b5fd574cd004a94304c2d228 to your computer and use it in GitHub Desktop.
Save antonfisher/d6de3ae8b5fd574cd004a94304c2d228 to your computer and use it in GitHub Desktop.
Simple S3 test using minio/mc client
#!/usr/bin/env bash
# setup:
# $ mkdir -p /tmp/s3 && cd /tmp/s3
# $ ~/js/nexenta/nef.extra/mc/test.sh 2>&1 | grep --color -E "^\+.+$|$"
set -x;
#set -e;
HOST="1.1.1.1:9000"
ACCESS_KEY="lololol"
SECTRET_KEY="kekekek"
BUCKET="mc1"
OBJECT="image.png"
OBJECT_BIG="../s3cmd/archive.zip" # path to any big file
# create bucket
#minio-mc ls ns
#minio-mc mb ns/${BUCKET}
# upload object
minio-mc --insecure ls nss/${BUCKET}
rm ${OBJECT} || true
echo "TIME:$(date)" >${OBJECT} || true
minio-mc --insecure cp ${OBJECT} nss/${BUCKET}
#minio-mc ls ns/${BUCKET}
#minio-mc ls ns
# download object
rm "${OBJECT}.downloaded" || true
minio-mc --insecure cp nss/${BUCKET}/${OBJECT} "${OBJECT}.downloaded"
ls -lha ${OBJECT}*
cat ${OBJECT}
cat "${OBJECT}.downloaded"
#tail -1 ${OBJECT} | cut -c -80
#tail -3 "${OBJECT}.downloaded" | cut -c -80
set +x
MD5_1=$(md5sum ${OBJECT})
MD5_2=$(md5sum ${OBJECT}.downloaded)
# copy object
#minio-mc cp ns/${BUCKET}/${OBJECT} ns/${BUCKET}/image2.png
#minio-mc ls ns/${BUCKET}
# multipart
#minio-mc cp ${OBJECT_BIG} ns/${BUCKET}
# delete object
#minio-mc rm ns/${BUCKET}/${OBJECT}
#minio-mc rm ns/${BUCKET}/${OBJECT_BIG}
#minio-mc ls ns/${BUCKET}
# delete bucket
#minio-mc rb ns/${BUCKET}
#minio-mc ls
set +x
echo ""
echo "Results:"
echo "------ --------------------------------"
echo "MD5_1: ${MD5_1}"
echo "MD5_2: ${MD5_2}"
echo "------ --------------------------------"
if [ "${MD5_1:0:32}" == "${MD5_2:0:32}" ]; then
echo "OK"
else
echo "FAIL"
exit 1
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment