亚马逊IOS SDK亚马逊弹性跨codeR REST调用 [英] Rest call with amazon ios sdk to amazon elastic transcoder

查看:167
本文介绍了亚马逊IOS SDK亚马逊弹性跨codeR REST调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了看文档,我不看的弹性转换SDK为iOS的支持。 我用例是从bucket1以MP4格式转code移动的文件videoFile.mp4和创建文件videoFile.webm再次回到bucket1。

我怎么可以使用Amazon的SDK(code样品),使剩下的调用来执行这项任务?

更新: 我能够得到的东西去,但我有另外一个问题。 但我得到的时候我正在调用的 HTTPS://elastictrans$c$cr.us-west-2.amazonaws.com/2014-06-16/jobs

 < InvalidSignatureException>
  <消息>凭证应作用于正确的服务:elastictrans codeR'。 < /消息>
< / InvalidSignatureException>
 

在code以下是我曾尝试。

  AmazonCredentials *证书= [[AmazonCredentials页头]初始化];
    credentials.secretKey = SECRET_KEY;
    credentials.accessKey = ACCESS_KEY_ID;

    NSMutableDictionary的*参数= [NSMutableDictionary的dictionaryWithObjectsAndKeys:
// dateString1,@X-AMZ-日,
                                      @elastictrans coder.us-west-2.amazonaws.com:443,@主持人,
                                      @应用程序/ x-AMZ-JSON-1.0,@内涵式
                                      长度,@内容长度,
                                      零];

    AmazonServiceRequest *请求= [[AmazonServiceRequest页头]初始化];
    request.urlRequest.HTTPMethod = @POST;
    request.regionName = @美西-2;
    request.serviceName = @ETS;
    NSLog(@"***********************************************************************************************");
    NSLog(@"***********************************************************************************************");
    [AmazonAuthUtils signRequestV4:请求头:参数有效载荷:jsonStringData凭据:凭据]。
    NSLog(@"***********************************************************************************************");
    NSLog(@"***********************************************************************************************");




    NSMutableURLRequest * mutableRequest = [[NSMutableURLRequest页头]
                                    initWithURL:[NSURL
                                                 URLWithString:@的https://elastictrans$c$cr.us-west-2.amazonaws.com]];
    [mutableRequest setHTTPMethod:@POST];
    对于(参数号键){
        [mutableRequest的setValue:[参数objectForKey:键] fo​​rHTTPHeaderField:键]
    }
    的NSLog([request.urlRequest valueForHTTPHeaderField:@X-AMZ-日]);
    的NSLog([request.urlRequest valueForHTTPHeaderField:@授权]);
    //添加授权签名和日期
    [mutableRequest的setValue:[request.urlRequest valueForHTTPHeaderField:@X-AMZ-日] forHTTPHeaderField:@X-AMZ-日];
    [mutableRequest的setValue:[request.urlRequest valueForHTTPHeaderField:@授权】forHTTPHeaderField:@授权];
    [mutableRequest setHTTPBody:[jsonStringData dataUsingEncoding:NSUTF8StringEncoding]];
    [[NSURLConnection的页头] initWithRequest:mutableRequest代表:个体经营];
 

解决方案

在一般情况下,你应该建立从AWS管理控制台管道,因为它是一次性设置。它没有任何意义创建从移动设备上的管道。从移动设备,你应该只是视频文件上传到您的Amazon S3存储。后端服务器(如亚马逊的EC2和AWS弹性魔豆都是不错的选择)应监测桶和创造就业机会的弹性跨codeR。 AWS刚刚宣布AWS LAMBDA,你可能要检查它。一旦任务完成,您可以使用Amazon SNS得到通知。

I looked at the docs and i don't see support for elastic transcoding sdk for ios. My use case is to move the file "videoFile.mp4" from "bucket1" in mp4 format to transcode and create the file "videoFile.webm" again back to "bucket1".

How can i use amazon sdk(code sample) to make the rest calls to do this task?

UPDATE: I am able to get something going but i am having another issue. But i am getting this message when I am making the call to https://elastictranscoder.us-west-2.amazonaws.com/2014-06-16/jobs

<InvalidSignatureException>
  <Message>Credential should be scoped to correct service: 'elastictranscoder'. </Message>
</InvalidSignatureException>

The code below is what i have tried.

  AmazonCredentials *credentials = [[AmazonCredentials alloc] init];
    credentials.secretKey = SECRET_KEY;
    credentials.accessKey = ACCESS_KEY_ID;

    NSMutableDictionary *parameter = [NSMutableDictionary dictionaryWithObjectsAndKeys:
//                                    dateString1, @"x-amz-date",
                                      @"elastictranscoder.us-west-2.amazonaws.com:443",@"host",
                                      @"application/x-amz-json-1.0", @"content-type",
                                      length, @"content-length",
                                      nil];

    AmazonServiceRequest *request = [[AmazonServiceRequest alloc] init];
    request.urlRequest.HTTPMethod = @"POST";
    request.regionName = @"us-west-2";
    request.serviceName = @"ets";
    NSLog(@"***********************************************************************************************");
    NSLog(@"***********************************************************************************************");
    [AmazonAuthUtils signRequestV4:request headers:parameter payload:jsonStringData credentials:credentials];
    NSLog(@"***********************************************************************************************");
    NSLog(@"***********************************************************************************************");




    NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc]
                                    initWithURL:[NSURL
                                                 URLWithString:@"https://elastictranscoder.us-west-2.amazonaws.com"]];
    [mutableRequest setHTTPMethod:@"POST"];
    for(id key in parameter){
        [mutableRequest setValue:[parameter objectForKey:key] forHTTPHeaderField:key];
    }
    NSLog([request.urlRequest valueForHTTPHeaderField:@"x-amz-date"]);
    NSLog([request.urlRequest valueForHTTPHeaderField:@"Authorization"]);
    // add the Authorization signature and the date
    [mutableRequest setValue:[request.urlRequest valueForHTTPHeaderField:@"x-amz-date"] forHTTPHeaderField:@"x-amz-date"];
    [mutableRequest setValue:[request.urlRequest valueForHTTPHeaderField:@"Authorization"] forHTTPHeaderField:@"Authorization"];
    [mutableRequest setHTTPBody:[jsonStringData dataUsingEncoding:NSUTF8StringEncoding]];
    [[NSURLConnection alloc] initWithRequest:mutableRequest delegate:self];

解决方案

In general, you should set up a pipeline from the AWS Management Console because it is a one-time setup. It does not make sense to create a pipeline from mobile devices. From mobile devices, you should just upload video files to your Amazon S3 bucket. A backend server (e.g. Amazon EC2 and AWS Elastic Beanstalk are both good options) should monitor the bucket and create jobs for Elastic Transcoder. AWS just announced AWS Lambda, and you may want to check it. Once the job is done, you can use Amazon SNS to get notified.

这篇关于亚马逊IOS SDK亚马逊弹性跨codeR REST调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆