I have a content type with a machine name of "video" and I created a module called "df". I want to add a separate form to the content type (above or below the edit fields) that does a direct post to Amazon S3 using the S3BrowserUpload object from the AWS SDK. The steps I am trying to accomplish are:

  1. Create additional upload form on "video" content type.
  2. User enters information and specifies a file in the S3 upload form.
  3. User clicks Save for the Add Content Type page.
  4. Ajax fires the Amazon S3 POST form to upload the video file and handles the response to store the file's key path in a hidden field.
  5. The normal drupal add content type fields are then posted back to the drupal site and processed. It would also have access to the hidden field that had been populated with Ajax.

I am new to Drupal forms so any assistance in integrating S3BrowserUpload with Drupal's forms API in my custom module to accomplish the steps above would be greatly appreciated.

1 Answer 1


Recently I worked on a project to integrate JW Player into a Drupal 7 site where the videos stream from an S3 bucket. There was also some Zencoder stuff going on but that is not really relevant here I don't think.

Currently we don't upload directly to S3 though, the project ran out of time before we could implement that. What the client does is upload the files directly to S3 and then reference the file in the content type using the Remote File Source module. That is not quite what you are trying to do though.

I have had a look around and see there is an Amazon S3 CORS Upload module which looks promising and might be able to help you. It creates a new form field #type which you can use in your module.

If none of that appeals to/works for you :) then you can use hook_form_alter to add a new custom upload field to the content type form, it is kind of messy but it will work. Then you add an extra submit handler to the form to catch your file. You can then use the code from this example to submit your file to S3.

The nicer way would be to create a new Field using the Drupal 7 Field API.

  • I was hoping for a more concrete example but the CORS module is certainly interesting. I'll have to take a look.
    – Adam
    Mar 30, 2013 at 21:13
  • @Adam Oh, ok... sorry about that :/. If the CORS module doesn't work out then I am happy to fiddle with some code examples :)
    – theamoeba
    Apr 1, 2013 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.