0

在应用程序中 didFinishLaunchingWithOptions

    let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "my-identity-pool-id")
    let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
    AWSFirehoseRecorder.register(with: configuration!, forKey: "somestupidkey")

在视图控制器中

let firehoseRecorder = AWSFirehoseRecorder(forKey: "somestupidkey")
let yourData = "Test_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_dataTest_data".data(using: .utf8)
firehoseRecorder.saveRecord(yourData, streamName: kinesisDirectory)

NSLog("Added %d records", firehoseRecorder.diskBytesUsed) // ALWAYS ZERO!!!!

看起来它根本没有写入数据。diskBytesUsed总是返回0。知道可能是什么问题吗?
谢谢

4

1 回答 1

0

好的,解决了。它变成了身份验证问题。因此,使用此代码实际上会捕获记录未提交原因的错误消息:

            firehoseRecorder?.saveRecord(jsonData, streamName: "YourStreamName").continueOnSuccessWith(block: { (task:AWSTask) -> AWSTask? in
                NSLog("RecordBeen saved")
                return nil;
            }).continueWith(block: { (task:AWSTask) -> Any? in
                if let error = task.error as? NSError {
                    print("Error: \(error)")
                    return nil
                }
                return nil
            })

显示错误消息实际上有所帮助。

希望它可以帮助其他有同样问题的人。

谢谢。

于 2018-01-14T07:41:03.987 回答