Метод загрузки AWSTransferUtility не запускается - PullRequest
1 голос
/ 27 сентября 2019

Здравствуйте, я пытаюсь загрузить видео с помощью AWS S3. Здесь я добавил свой код, но ни одна из задач загрузки не дает мне ответ, даже не выдается сообщение об ошибке.

AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionAPNortheast1 identityPoolId:@"us-east-1:"];
    AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];
    AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;


    // 3. Create Transfer Utility

    [AWSS3TransferUtility registerS3TransferUtilityWithConfiguration:configuration forKey:@"transfer-utility-with-advanced-options"];

    AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility S3TransferUtilityForKey:@"transfer-utility-with-advanced-options"];



    AWSS3TransferUtilityUploadExpression *expression = [AWSS3TransferUtilityUploadExpression new];



    [transferUtility uploadFile:fileURL1 bucket:@"bucket_name" key:@"keey" contentType:@"video/quicktime" expression:expression completionHandler:^(AWSS3TransferUtilityUploadTask * _Nonnull task, NSError * _Nullable error) {

        if (error != nil){
            NSLog(@"error = %@",error.localizedDescription);
        }else{
            if(!isImageChanging)
                [self createImageView:[Common getImage:fileURL1]];
            else
                [self changeImageSelectedImage:changingImageTagNo newImage:[Common getImage:fileURL1]];
        }
    }];
    NSData *dt=[NSData dataWithContentsOfURL:fileURL1];

    [transferUtility uploadData:dt bucket:@"sqoberawfiles" key:@"AKIAIZ27S5EQH7HN5MKA" contentType:@"video/quicktime" expression:expression completionHandler:^(AWSS3TransferUtilityUploadTask * _Nonnull task, NSError * _Nullable error) {
        if (error != nil){
            NSLog(@"error = %@",error.localizedDescription);
        }else{
            if(!isImageChanging)
                [self createImageView:[Common getImage:fileURL1]];
            else
                [self changeImageSelectedImage:changingImageTagNo newImage:[Common getImage:fileURL1]];
        }
    }];

    AWSS3TransferUtilityUploadCompletionHandlerBlock completionHandler = ^(AWSS3TransferUtilityUploadTask *task, NSError *error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error) {
                NSLog(@"error = %@",error.localizedDescription);
            } else {
                NSLog(@"error = %@",@"Success");
            }
        });
    };

    AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];
    AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
    uploadRequest.bucket = @"sqs";
    uploadRequest.key = @"AKIA5MKA";
    uploadRequest.body = fileURL1;
    uploadRequest.contentLength = [NSNumber numberWithUnsignedLongLong:123333333333];

    [[transferManager upload:uploadRequest] continueWithBlock:^id(AWSTask *task) {
        // Do something with the response
        return nil;
    }];

    // 4. Rewire Transfer Utility blocks

    expression.progressBlock = ^(AWSS3TransferUtilityTask *task, NSProgress *progress) {
        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"%f",progress.fractionCompleted);
        });
    };

У меня естьПопытка с AWSS3TransferManager устарел метод в том, что я получаю сообщение об ошибке как Ошибка Domain=com.amazonaws.service.cognitoidentity.AWSCognitoCredentialsProviderHelper Code=0 "Obtaining an identity id in another thread failed or didn't complete within 5 seconds." UserInfo={NSLocalizedDescription=Obtaining an identity id in another thread failed or didn't complete within 5 seconds.}

Мои имя корзины и ключ в порядке и все из того же региона.Пожалуйста, помогите мне, что пошло не так!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...