最近我开始测试Firebase新文档db Firestore用于学习目的,我现在卡在文档内作为对象访问值存储.
我使用下面的代码来访问Privacy存储在文档中的对象,但我不知道如何访问Key - Value?例如Key - Value,对象中有3个子对,我将如何单独访问和编辑它?
DocumentReference docRef = FirebaseFirestore.getInstance().collection("Users").document("PQ8QUHno6QdPwM89DsVTItrHGWJ3");
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document != null) {
Log.d(TAG, "DocumentSnapshot data: " + task.getResult().getData().get("privacy"));
Object meta_object = task.getResult().getData().get("privacy");
} else {
Log.d(TAG, "No such document");
}
} else {
Log.d(TAG, "get failed with ", task.getException());
}
}
});
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏,谢谢.
已按照文档 ( https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html )为我的 AWS API Gateway 创建了一个简单的基于请求的授权方
在测试授权者时(使用虚拟设置来验证授权头中是否有关键的“测试”),授权者工作正常,但是当直接从端点调用 API 时,授权者根本不会被调用,并且我得到了 API 响应(应该被阻止,因为没有传递标头)。
使用无效密钥进行授权者测试:得到预期的 401
使用有效密钥进行授权者测试:获得预期 200
直接从Web调用API endpoing成功:
我的 API Gateway 资源策略只想限制来自特定 IP 范围的调用:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:us-east-1:111111111111:6mm9kw17uf/*/*/*"
},
{
"Effect": "Deny",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:us-east-1:111111111111:6mm9kw17uf/*/*/*",
"Condition": {
"NotIpAddress": {
"aws:SourceIp": "XXXXXXX"
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
授权者 Lambda 代码:
exports.handler = function(event, context, callback) {
console.log('Received event:', JSON.stringify(event, null, 2));
// Retrieve request parameters from the …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-lambda aws-api-gateway lambda-authorizer
一直在尝试按照此处的教程设置 AWS 管道:https : //docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html
以下是一些我已经尝试过的操作:
下面是我的 buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
build:
commands:
- npm install
- export BUCKET=xx-test
- aws cloudformation package --template-file template.yaml --s3-bucket $BUCKET --output-template-file outputtemplate.yml
artifacts:
type: zip
files:
- template.yml
- outputtemplate.yml
Run Code Online (Sandbox Code Playgroud)
下面是我的 template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
helloWorld
DZ Bank API Gateway connectivity helloWorld
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./ …Run Code Online (Sandbox Code Playgroud) amazon-s3 amazon-web-services aws-cloudformation aws-codepipeline aws-codebuild