Hello Techie's,
we can use below Shell script to check if particular file present in s3 bucket.
#--------------------------------------------------------------------
#s3 Bucket Credentials
#--------------------------------------------------------------------
s3_access_key=XXXXXXXXXXX
s3_secret_key=XXXXXXXXXXX
host=s3_bucket_api_url
bucket=s3_bucket_name
folder_name=name_of_the folder_in_bucket
file_name=name_of_the_file_to_check
#--------------------------------------------------------------------
#curl command variables
#--------------------------------------------------------------------
dateValue=`date -R`
contentType="application/xml"
filepath="/${bucket}/${folder_name}/${file_name}
signature_string="GET\n\${contentType}\n${dateValue}\n${filepath}"
signature_hash=`echo -en ${signature_string} | openssl sha1 -hmac ${s3_secret_key} -binary | base64`
#--------------------------------------------------------------------
#Curl command to check if file exists
#--------------------------------------------------------------------
FILE=$((($(curl -X GET \
-H "Host: ${host}" \
-H "Date: ${dateValue}" \
-H "Content-Type: ${contentType}" \
-H "Authorization: Aws ${s3_access_key}:${signature_hash}" \
--silent -I https://${host}/${bucket}/${folder_name}/${file_name} \
| grep -E "^HTTP" \
| awk -F " " '{print $2}') == 200)) \
&& echo "file exists")
#--------------------------------------------------------------------
#Check If File exists
#--------------------------------------------------------------------
if [ "${FILE}" = "file exists" ]; then
echo "file is already present in s3 bucket folder"
else
echo "file is not present in s3 bucket folder"
fi
#-------------------------------------------------------------------
betmatik
ReplyDeletekralbet
betpark
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
CG8L
شركة مكافحة الحمام بالاحساء L2QfcUdZOo
ReplyDelete<a href="https://almthaly-dammam.com/%d8%b4%d8%b1%d9%83%d8%a9-%d8%aa%d9%86%d8%b8%d9%8a%d9%81-%d9%85%d8%ac%d8%a7%d9%84%d8%b3-%d8%a8%d8%a7%d9%84%d8%ae%d8%a8%
ReplyDelete