I'm using Amazon S3 to store my video files. The files on the bucket are kept private, and access is granted through bucket policies.

Everything was working fine, until I decided to use a CNAME for the bucket (bucketname -> bucketname.s3.amazonaws.com). I enabled CNAME on the AmazonS3 module, but then Zencoder jobs report that the original video file could not be downloaded, due to an HTTP 403 response.

According to Zencoder docs (https://app.zencoder.com/docs/guides/getting-started/working-with-s3): "When using a bucket policy you should always use URLs in the s3://BUCKET/KEY format so that Zencoder is sure to identify them as S3 URLs and sign the request appropriately."

Also, if the URL contains "s3.amazonaws.com", Zencoder identifies it is a S3 bucket, and send the appropriate identity (that's why it worked before the CNAME). But now the URL is something like http://bucketname/video/test.mov, and Zencoder doesn't recognize it as a bucket anymore.

To workaround this, I modified the TranscoderAbstractionFactoryZencoder.setInput() method to change the protocol of the URL, from http:// to s3://, and now things are working again. Zencoder receives a URL like s3://bucketname/video/test.mov, transforms it to http://bucketname.s3.amazonaws.com/video/test.mov, sends the authetication data and the job succeeds.

Comments

Jorrit’s picture

When you say http://bucketname/video/test.mov, you mean http://your.cname.com/video/test.mov?
Are you using S3 to store the original video files? This is the 'Upload destination of original file' setting for your Video field(s).

Jorrit’s picture

Status: Active » Postponed (maintainer needs more info)

Also, have you setup anything in the 'Presigned URLs' field at admin/config/media/amazons3 ? When using that field, the CNAME should be disregarded. Setting that to for instance 60|videos/* should solve your problem.

If the files in your bucket are private, how are users able to download them?

tomyinhauser’s picture

Yes, I mean 'http://your.cname.com/video/test.mov', and all the destinations in the video field (original, converted and thumbnails) point to Amazon S3. I'm using presigned URLs, but not for this content type. The converted videos are enabled to the end users based on bucket policies, but the original videos are kept private, and shared only with the Zencoder AWS account.

tomyinhauser’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

The problem persists, but the conditions have changed.

AmazonS3 module has released a bug fix (https://drupal.org/node/1555086), and now it serves files using the default page protocol to support HTTPs properly: '//mybucketdomain/path-to-file' instead of 'http://mybucketdomain/path-to-file'.

Since Zencoder enforces the protocol in the input url, it returns the following error message to the api request: "{"errors":["Input media file url of input file is not well formed. Please confirm that it is a valid URL."]}"

The TranscoderAbstractionFactoryZencoder should append 'http:' or 's3:' to it, depending on the file storage configuration.

heshanlk’s picture

Component: Zencoder » General
Status: Active » Closed (works as designed)