Ios AWS S3桶问题
有人能帮我找到如何使用客户端Ios AWS S3桶问题,ios,objective-c,amazon-web-services,amazon-s3,aws-sdk,Ios,Objective C,Amazon Web Services,Amazon S3,Aws Sdk,有人能帮我找到如何使用客户端访问密钥ID和秘密访问密钥访问AWS S3 Bucket资源吗? 或者这是不推荐使用的AWS API?我找到了很多解决方案,但都使用了我不想使用的identityPoolId。您可以使用两种方式登录。 通过在代码中使用凭据 将您的凭据保存在一个文件中 通过在代码中使用凭据。 将您的凭据保存在一个文件中: 对于crud操作,您可以阅读本教程: 有关在特定存储桶中授予权限的信息,请查看图片: 添加权限: { "Version": "2008-10-17",
访问密钥ID
和秘密访问密钥
访问AWS S3 Bucket资源吗?
或者这是不推荐使用的AWS API?我找到了很多解决方案,但都使用了我不想使用的
identityPoolId
。您可以使用两种方式登录。
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::riz-bucket001/*"
}
]
}
N.B:此桶策略使桶中的所有内容都公开可读。所以要小心使用它。如果你用学习的目的,那么好。但出于商业目的,不要使用它。
非常感谢
您可以根据需要在此处查看更多策略:您所说的存储桶资源是什么意思?举个例子。你可能想考虑使用。它为Amazon S3提供了特定的命令。哇——这里有一个潜在的危险建议——bucket策略使bucket中的所有内容都可以公开阅读。@Michael sqlbot感谢您的指点。我已经更新了ans,并告知您只能将其用于学习目的,而不能用于商业目的。
/*
* Create your credentials file at ~/.aws/credentials (C:\Users\USER_NAME\.aws\credentials for Windows users)
* and save the following lines after replacing the underlined values with your own.
*
* [default]
* aws_access_key_id = YOUR_ACCESS_KEY_ID
* aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
*/
AWSCredentials credentials = new ProfileCredentialsProvider().getCredentials();
AmazonS3 s3 = new AmazonS3Client(credentials);
// Create a bucket
System.out.println("Creating bucket " + bucketName + "\n");
s3.createBucket(bucketName);
/*
* List the buckets in your account
*/
System.out.println("Listing buckets");
for (Bucket bucket : s3.listBuckets()) {
System.out.println(" - " + bucket.getName());
}
/*
* Delete an object - Unless versioning has been turned on for your bucket,
* there is no way to undelete an object, so use caution when deleting objects.
*/
System.out.println("Deleting an object\n");
s3.deleteObject(bucketName, key);
/*
* Delete a bucket - A bucket must be completely empty before it can be
* deleted, so remember to delete any objects from your buckets before
* you try to delete them.
*/
System.out.println("Deleting bucket " + bucketName + "\n");
s3.deleteBucket(bucketName);
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::riz-bucket001/*"
}
]
}