I am trying to create a shell script that will upload our tiffs to mapbox using their API. I retrieve the temporary credentials from the initial curl post but when it comes to copying the data across via aws' cp command I get the error Access denied when calling the CreateMultipartUpload operation.
I am assuming that this error is to do with credentials being stored incorrectly. My code is as follows:
#save curl response as var
ans=`curl -X POST "https://api.mapbox.com/uploads/v1/xxx/credentials?access_token=$token"`
#extract necessary info from var
key=`echo $ans | grep -zoP '"key":s*"K[^s,]*(?=s*",)'`
bucket=`echo $ans | grep -zoP '"bucket":s*"K[^s,]*(?=s*",)'`
accessKeyId=`echo $ans | grep -zoP '"accessKeyId":s*"K[^s,]*(?=s*",)'`
secretAccessKey=`echo $ans | grep -zoP '"secretAccessKey":s*"K[^s,]*(?=s*",)'`
sessionToken=`echo $ans | grep -zoP '"sessionToken":s*"K[^s,]*(?=s*",)'`
#export env variables for auth
export AWS_ACCESS_KEY_ID=$accessKeyId
export AWS_SECRET_ACCESS_KEY=$secretAccessKey
export AWS_SESSION_TOKEN=$sessionToken
#copy data across
aws s3 cp $inputdir s3://$bucket/$key/ --recursive --region us-east-1
Any help would be much appreciated.
question from:
https://stackoverflow.com/questions/65941933/trying-to-upload-tiffs-to-mapbox-i-get-access-denied-when-calling-the-createmul 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…