title: Retrieve file and thumbnail url from AWS Elastic Transcoder job
body: <p>I have a rails app which uploads videos to an AWS S3 bucket using their CORS configuration, when this is completed and the rails video object is created an Elastic Transcoder job is created to encode the video to .mp4 format and generate a thumbnail image, AWS SNS is enabled to send push notifications when the job is complete.</p>
  
  <p>The process all works nicely and I receive a SNS notification when the upload is complete, however I can fetch the video url just fine but the notification only contains the thumbnail pattern rather than the actual filename.</p>
  
  <p>Below is a typical notification I receive from AWS SNS. NB. This is from the outputs hash</p>
  
  <pre><code>{"id"=&gt;"1", "presetId"=&gt;"1351620000001-000040", "key"=&gt;"uploads/video/150/557874e9-4c67-40f0-8f98-8c59506647e5/IMG_0587.mp4", "thumbnailPattern"=&gt;"uploads/video/150/557874e9-4c67-40f0-8f98-8c59506647e5/{count}IMG_0587", "rotate"=&gt;"auto", "status"=&gt;"Complete", "statusDetail"=&gt;"The transcoding job is completed.", "duration"=&gt;10, "width"=&gt;202, "height"=&gt;360}
  </code></pre>
  
  <p>As you can see under thumbnailPattern is just the filepattern to use, and not the actual file created.</p>
  
  <p>Does anyone know how I can get the URLS to the files created over elastic transcoder and SNS?</p>
  
  <p>transcoder.rb # => I create a new transcoder object when a video has been saved</p>
  
  <pre><code>class Transcoder &lt; Video
    def initialize(video)
      @video = video
      @directory = "uploads/video/#{@video.id}/#{SecureRandom.uuid}/"
      @filename = File.basename(@video.file, File.extname(@video.file))
    end
  
    def create
      transcoder = AWS::ElasticTranscoder::Client.new(region: "us-east-1")
      options = {
        pipeline_id: CONFIG[:aws_pipeline_id],
        input: { 
          key: @video.file.split("/")[3..-1].join("/"), # slice off the amazon.com bit 
          frame_rate: "auto", 
          resolution: 'auto', 
          aspect_ratio: 'auto', 
          interlaced: 'auto', 
          container: 'auto' 
          },
        outputs: [
          {
            key: "#{@filename}.mp4", 
            preset_id: '1351620000001-000040', 
            rotate: "auto", 
            thumbnail_pattern: "{count}#{@filename}"
          }
        ],
        output_key_prefix: "#{@directory}"
      }
      job = transcoder.create_job(options)
      @video.job_id = job.data[:job][:id]
      @video.save!
    end
  end
  </code></pre>
  
  <p>VideosController #create</p>
  
  <pre><code>class VideosController &lt; ApplicationController
    def create
      @video = current_user.videos.build(params[:video])
      respond_to do |format|
        if @video.save
          transcode = Transcoder.new(@video)
          transcode.create
          format.html { redirect_to videos_path, notice: 'Video was successfully uploaded.' }
          format.json { render json: @video, status: :created, location: @video }
          format.js 
        else
          format.html { render action: "new" }
          format.json { render json: @video.errors, status: :unprocessable_entity }
        end
      end
    end
  end
  </code></pre>