Sys.setenv("AWS_ACCESS_KEY_ID" = ".............",
"AWS_SECRET_ACCESS_KEY" = "...............",
"AWS_DEFAULT_REGION" = "......")
查看存储桶:
get_bucket(bucket = "....",
check_region = FALSE,
verbose = TRUE)
上面的代码工作,并返回存储桶的内容。
将对象保存到s3:
s3save(data,
object = ".....",
bucket = ".....")
错误返回:
List of 4
$ Code : chr "AccessDenied"
$ Message : chr "Access Denied"
$ RequestId: chr ""
$ HostId : chr ""
- attr(*, "headers")=List of 6
..$ x-amz-request-id : chr ""
..$ x-amz-id-2 : chr ""
..$ content-type : chr "application/xml"
..$ transfer-encoding: chr "chunked"
..$ date : chr "Tue, 05 Sep 2017 13:23:42 GMT"
..$ server : chr "AmazonS3"
..- attr(*, "class")= chr [1:2] "insensitive" "list"
- attr(*, "class")= chr "aws_error"
- attr(*, "request_canonical")= chr "GET\n/"| __truncated__
- attr(*, "request_string_to_sign")= car ""| __truncated__
- attr(*, "request_signature")= chr "AWS4-HMAC-SHA256 Credential=|
__truncated__
NULL
Error in parse_aws_s3_response(r, Sig, verbose = verbose) :
Forbidden (HTTP 403).
解决此问题的任何方法。
答案 0 :(得分:0)
@ audiracmichelle,@ Prakhar,使用aws.s3库中的函数import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var application: UIApplication?
@objc var currentUnityController: UnityAppController!
var isUnityRunning = false
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
self.application = application
unity_init(CommandLine.argc, CommandLine.unsafeArgv)
currentUnityController = UnityAppController()
currentUnityController.application(application, didFinishLaunchingWithOptions: launchOptions)
// first call to startUnity will do some init stuff, so just call it here and directly stop it again
startUnity()
stopUnity()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
if isUnityRunning {
currentUnityController.applicationWillResignActive(application)
}
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
if isUnityRunning {
currentUnityController.applicationDidEnterBackground(application)
}
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
if isUnityRunning {
currentUnityController.applicationWillEnterForeground(application)
}
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
if isUnityRunning {
currentUnityController.applicationDidBecomeActive(application)
}
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
if isUnityRunning {
currentUnityController.applicationWillTerminate(application)
}
}
func startUnity() {
if !isUnityRunning {
isUnityRunning = true
currentUnityController.applicationDidBecomeActive(application!)
}
}
func stopUnity() {
if isUnityRunning {
currentUnityController.applicationWillResignActive(application!)
isUnityRunning = false
}
}
}
,如下所示。函数put_object的put_object
输入参数是对象在s3中应具有的名称(字符串)。
您可以首先使用以下方法从内存中写入序列化的对象(在这种情况下为object
):
data
然后将对象保存到S3存储桶:
in_mem_obj <- rawConnection(raw(0), "w")
utils::write.table(data, in_mem_obj, sep = "\t", na = "", quote = TRUE,
row.names = FALSE, fileEncoding="UTF-8")
答案 1 :(得分:0)
您的IAM帐户似乎无权执行该操作。 如果您是AWS账户的所有者,则可以转到AWS Service IAM,单击用户,选择该IAM用户并向其添加必要的授权。