Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws transcoder overwrite files on s3

I'm using the AWS PHP SDK to upload a file to S3 then trancode it with Elastic Transcoder.

First pass everything works fine, the putobject command overwrites the old file (always named the same) on s3:

$s3->putObject([
      'Bucket'     => Config::get('app.aws.S3.bucket'),
      'Key'        => $key,
      'SourceFile' => $path,          
      'Metadata'   => [
        'title'     => Input::get('title')
      ]
    ]);

However when creating a second transcoding job, i get the error:

  The specified object could not be saved in the specified bucket because an object by that name already exists

the transcoder role has full s3 access. Is there a way around this or will i have to delete the files using the sdk everytime before its transcoded?

my create job:

    $result = $transcoder->createJob([
      'PipelineId' => Config::get('app.aws.ElasticTranscoder.PipelineId'),
      'Input' => [
        'Key' => $key
      ],
      'Output' => [
        'Key' => 'videos/'.$user.'/'.$output_key,
        'ThumbnailPattern' => 'videos/'.$user.'/thumb-{count}',
        'Rotate' => '0',
        'PresetId' => Config::get('app.aws.ElasticTranscoder.PresetId')       
      ],
    ]);
like image 238
Kudos Avatar asked Apr 01 '14 10:04

Kudos


People also ask

Can I overwrite a file in S3?

Simply upload your new file on top of your old file to replace an old file in an S3 bucket. The existing file will be overwritten by your new file.

What does Amazon Elastic transcoder do?

Amazon Elastic Transcoder is media transcoding in the cloud. It is designed to be a highly scalable, easy to use and a cost effective way for developers and businesses to convert (or “transcode”) media files from their source format into versions that will playback on devices like smartphones, tablets and PCs.

Where is elastic transcoder used?

You can use Amazon Elastic Transcoder to convert video and audio files into supported output formats optimized for playback on desktops, mobile devices, tablets, and televisions.

What is the maximum size of an S3 object?

Individual Amazon S3 objects can range in size from a minimum of 0 bytes to a maximum of 5 TB. The largest object that can be uploaded in a single PUT is 5 GB.


1 Answers

The Amazon Elastic Transcoder service documents that this is the expected behavior here: http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/job-settings.html#job-settings-output-key.

If your workflow requires you to overwrite the same key, then it sounds like you should have the job output somewhere unique and then issue an S3 CopyObject operation to overwrite the older file.

like image 128
Jeremy Lindblom Avatar answered Sep 21 '22 10:09

Jeremy Lindblom