Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8110957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:56:28+00:00 2026-06-06T01:56:28+00:00

I am trying to do a presigned post to S3 with SWFUpload and AWS-SDK.

  • 0

I am trying to do a presigned post to S3 with SWFUpload and AWS-SDK. Long story short, it’s not working.

I set up SWFUpload thusly (pardon the coffeescript):

@swfu = new SWFUpload
         flash_url: "<%= asset_path 'swfupload.swf' %>"
         file_size_limit: "1000 MB"
         file_types: "*.mp3"
         file_queue_limit:1
         debug: true
         upload_url: "http://<%= configatron.aws.cms.bucket %>.s3.amazonaws.com"
         button_placeholder_id : "SWFUploadButton"
         button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE
         button_width: '112'
         button_height: '33'
         button_text: '<button class="orange-button">Upload MP3s</button>',
         button_cursor : SWFUpload.CURSOR.HAND
         http_success : [201, 303, 200]
         file_post_name: "file"
         file_queued_handler: (data) =>
           @queued(data)

When a file is queued, this is run:

$.ajax
  url: '/uploads/new'
  data: { key: file.name, bucket: '<%= configatron.aws.cms.bucket %>' }
  success: (data) =>
    @upload(data)

/uploads/new points to a controller which returns JSON, in the end, from this line, using the aws-sdk gem (I’ve snipped some bits about instantiating the bucket):

  policy = bucket.presigned_post key: key, success_action_status: 201, acl: 'public-read'
  render json: policy

A sample JSON response looks like this:

{"AWSAccessKeyId":"MY_KEY_ID",
 "key":"blutrotermond.mp3",
 "policy":"base64-encoded-policy",
 "signature":"the-signature",
 "acl":"public-read",
 "success_action_status":"201"}

Back in javascript land, armed with a signature, I take this response and add the parameters to SWFUpload:

upload: (data) ->
  @swfu.setPostParams data
  console.log "uploading...."
  @swfu.startUpload()

SWFUpload’s console then tells me that Amazon is unhappy with my signature process (or so I assume, as whatever magic SWFUpload does means that the POST itself does not appear in Chrome’s inspector, denying me a more direct look at what is being posted):

SWF DEBUG: Event: fileQueued : File ID: SWFUpload_0_0
SWF DEBUG: Event: fileDialogComplete : Finished processing selected files. Files selected: 1. Files Queued: 1
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0
SWF DEBUG: Global Post Item: signature=signature
SWF DEBUG: Global Post Item: acl=public-read
SWF DEBUG: Global Post Item: AWSAccessKeyId=MY_KEY_ID
SWF DEBUG: Global Post Item: key=blutrotermond.mp3
SWF DEBUG: Global Post Item: success_action_status=201
SWF DEBUG: Global Post Item: policy=MY_ENCODED_POLICY
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for upload.  Starting upload to http://my-bucket.s3.amazonaws.com for File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 490792. Total: 2167327
SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 2167327. Total: 2167327
SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 403.
SWF DEBUG: Event: uploadComplete : Upload cycle complete.

I’ve gotten down into the guts of AWS-SDK, and this is what the policy is, and what’s being signed. It seems right to me.

{"expiration":"2012-05-02T19:33:31Z",
 "conditions":[{"bucket":"my-bucket"},
               {"key":"blutrotermond.mp3"},
               {"acl":"public-read"},
               {"success_action_status":"201"}]}

So I’m unsure how to further debug this; SWFUpload hides things from me and I’m not sure what’s wrong with my post parameters/signature. Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:56:29+00:00Added an answer on June 6, 2026 at 1:56 am

    The answer turned out to be that Flash adds a field to all post uploads, requiring adjustments to the parameters signed in the post. I added support for this field to the aws-sdk gem, and voila.

    For debugging, it’s possible to get an error response out of AWS by inspecting the exceptions that the aws-sdk throws with a little more detail. The actual Net::HTTP response is in there somewhere, and that had a descriptive error message that the exception messages themselves were swallowing.

    See https://github.com/amazonwebservices/aws-sdk-for-ruby/pull/43 for the code that added support for this to aws-sdk, and a quick example of the field to add to the post parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrieve some HTML files from Amazon s3 using AWS SDK
Trying to comply with StackOverflow's suggestion of asking a question, not creating a discussion,
I am currently working with an application not written by me but by one
Trying to import a custom UITableViewCell and it keeps giving me a file not
trying to work out how to install zipArchive extension with MAMP, but not having
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect
Trying to modify a database parameter group on AWS RDS with boto, I hit
trying to get a project working on my debian vm but foreman refuses to
friends i am trying to work with predesigned visual studio dotNet projects. so i
Trying to use this method (gist of which is use self.method_name in the FunnyHelper

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.