Elastic transcoder AWS creating job from Parse.com CloudCode Javascript http requests

375 views Asked by At

I created a pipeline on AWS Elastic Transcoder, and I'm trying to create jobs for it using its api. This is what I'm doing.

Parse.Cloud.define("createJobOnElastic", function(request, response){

  Parse.Cloud.httpRequest({
 
    method: 'POST',
    headers: {
     'Content-Type': 'application/json; charset=UTF-8',
     'Accept': '*/*',
     'Host': 'elastictranscoder.us-east-1.amazonaws.com:443',
     'Content-Length': '300',
     "x-amz-date": new Date().getTime()
    },

    url: 'https://aws.elastictranscoder.us-east-1.amazonaws.com:443/2012-09-25/jobs',
    body:{
        
        "Input":{
            "Key":"fullViewLq1teqJ1Ym-nHGwcJtRuL-1433857991.895335.mp4",
            "FrameRate":"auto",
            "Resolution":"auto",
            "AspectRatio":"auto",
            "Interlaced":"auto",
            "Container":"mp4"
          },
  "OutputKeyPrefix":"compressed/",
   "Outputs":[
      {
         "Key":"fullViewLq1teqJ1Ym-nHGwcJtRuL-1433857991.895335.mp4",
         "Rotate":"0",
         "PresetId":"1351620000001-000030"
      }
   ],
   "PipelineId":"xxxxxxxxx-xxxx"
 },
    success: function(httpResponse) {
            // console.log(httpResponse);

            alert("Worked TRANCODER");
            response.success();
            },
        error: function(httpResponse) {
            // console.error(httpResponse);
            alert("Did not work TRANSCODER");
            response.error(httpResponse);
        }
 
    });


});

I can see that my url is probably wrong, but thats because I can't really tell which url I should be sending the request to from their documentation here: http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/create-job.html#create-job-description

This is what I get as a response:

{"uuid":"7dd5e323-167f-fe75-ca64-0adeeebad099","status":0,"headers":{"Connection":"keep-alive","Content-Language":"en","Content-Length":"3871","Content-Type":"text/html","Date":"Tue, 09 Jun 2015 14:44:23 GMT","Mime-Version":"1.0","Server":"squid/3.1.19","Vary":"Accept-Language","X-Squid-Error":"ERR_DNS_FAIL 0"},"text":"Request failed; 56-111 Failure when receiving data from the peer; Connection refused","buffer":[],"cookies":{}}

Any feedback on how to do it will be great.

Thanks.

1

There are 1 answers

1
Mircea On

Couple of things here:

  • you cannot just post to the elastic transcoder endpoint without signing your request. All AWS services require that you sign the requests. See here: http://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html
  • you probably should not specify Host and Content-Length in headers.
  • it's a bit confusing that the output key is the same as the input key
  • you should probably show how the pipeline is created for completeness.