在DynamoDB中,可以ConditionExpression在单个属性上设置如下:
ConditionExpression: 'attribute_exists(user_id)'
Run Code Online (Sandbox Code Playgroud)
如果此ConditionExpression是在更新中定义的,并且user_id不存在,则ConditionExpression的计算结果为false并返回异常:
message: 'The conditional request failed',
code: 'ConditionalCheckFailedException',
requestId: 'KPFMA7S5P110FCOMLPMKP15UDBVV4KQNSO6AEMVJF66Q9ASUAAJG',
statusCode: 400
Run Code Online (Sandbox Code Playgroud)
尽管只有一个条件可以评估所有情况,但所有条件都明确时,DynamoDB不会报告哪个条件失败:
ConditionExpression: 'attribute_exists(user_id) and iq = 85'
Run Code Online (Sandbox Code Playgroud)
那么异常与上述相同,因此无法说出是什么导致条件评估为假。
有没有办法(甚至是骇人听闻的)从异常信息中获取更多详细信息?
默认情况下,如果ContentType未明确设置,boto3将上传文件到s3with Content-Type: binary/octet-stream。s3当用作静态托管时,这不好。到目前为止,已经有公关了。