iOS 应用程序:如何访问另一个用户保存在 Cognito 身份 ID 文件夹下的 S3 对象
iOS app: How to access S3 object saved under cognito identity id folder by another user
在我的 iOS 应用程序中,我完成了 AWS Cognito 用户身份验证。经过身份验证的用户能够将图像上传到受保护的文件夹,即受保护/{cognito user_identitiy_id}。经过身份验证的用户可以访问仅保存在其 user_identity_id 文件夹下的对象。一个用户如何访问其他用户的对象。 S3 文档说:-
Public:您应用的所有用户都可以访问。文件存储在您的 S3 存储桶中的 public/ 路径下。
受保护:所有用户可读,但只有创建用户可写。文件存储在 protected/{user_identity_id}/ 下,其中 user_identity_id 对应于该用户的唯一 Amazon Cognito 身份 ID。
私有:仅供个人用户访问。文件存储在 private/{user_identity_id}/ 下,其中 user_identity_id 对应于该用户的唯一 Amazon Cognito 身份 ID。
如果您使用 Amplify,则使用 Protected。拥有者有写入权限,其他人只能读取文件。
请帮助确认:
您的 S3 存储桶策略类似于 "Protected" 文件夹以限制用户访问:https://docs.amazonaws.cn/en_us/IAM/latest/UserGuide/reference_policies_examples_s3_cognito-bucket.html
在 iOS,假设您正在使用 Amplify,请按照以下步骤操作:https://aws-amplify.github.io/docs/ios/storage。请记住,在使用 Storage API.
之前,您必须先验证并交换凭据
另一个想要读取该文件的用户可以指定创建它的用户:
let options = StorageDownloadDataRequest.Options(accessLevel:.protected, targetIdentityId: "OtherUserId")
在我的 iOS 应用程序中,我完成了 AWS Cognito 用户身份验证。经过身份验证的用户能够将图像上传到受保护的文件夹,即受保护/{cognito user_identitiy_id}。经过身份验证的用户可以访问仅保存在其 user_identity_id 文件夹下的对象。一个用户如何访问其他用户的对象。 S3 文档说:-
Public:您应用的所有用户都可以访问。文件存储在您的 S3 存储桶中的 public/ 路径下。
受保护:所有用户可读,但只有创建用户可写。文件存储在 protected/{user_identity_id}/ 下,其中 user_identity_id 对应于该用户的唯一 Amazon Cognito 身份 ID。
私有:仅供个人用户访问。文件存储在 private/{user_identity_id}/ 下,其中 user_identity_id 对应于该用户的唯一 Amazon Cognito 身份 ID。
如果您使用 Amplify,则使用 Protected。拥有者有写入权限,其他人只能读取文件。
请帮助确认:
您的 S3 存储桶策略类似于 "Protected" 文件夹以限制用户访问:https://docs.amazonaws.cn/en_us/IAM/latest/UserGuide/reference_policies_examples_s3_cognito-bucket.html
在 iOS,假设您正在使用 Amplify,请按照以下步骤操作:https://aws-amplify.github.io/docs/ios/storage。请记住,在使用 Storage API.
之前,您必须先验证并交换凭据
另一个想要读取该文件的用户可以指定创建它的用户:
let options = StorageDownloadDataRequest.Options(accessLevel:.protected, targetIdentityId: "OtherUserId")