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

  • Home
  • SEARCH
  • 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 8483399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:05:33+00:00 2026-06-10T20:05:33+00:00

I am having a problem (with csrf) executing a direct upload to S3 using

  • 0

I am having a problem (with csrf) executing a direct upload to S3 using a POST.

Here is the code:

<form action="https://mymediaurl/" method="post" enctype="multipart/form-data">
    <input type="hidden" name="key" value="uploads/${filename}">
    <input type="hidden" name="AWSAccessKeyId" value="{{ access_key }}">
    <input type="hidden" name="acl" value="private">
    <input type="hidden" name="success_action_redirect" value="http://localhost/">
    <input type="hidden" name="policy" value="{{ policy }}">
    <input type="hidden" name="signature" value="{{ signature }}">
    <input type="hidden" name="Content-Type" value="image/jpeg">
    <!-- Include any additional input fields here -->

    File to upload to S3:
    <input name="file" type="file">
    <br>
    <input type="submit" value="Upload File to S3">
</form>

Here is the error:

<Code>AccessDenied</Code>
<Message>
    Invalid according to Policy: Extra input fields: csrfmiddlewaretoken
</Message>

Source code that includes the csfr:

<form action="https://mymediaurl/" method="post" enctype="multipart/form-data">
    <div style='display:none;'><input type='hidden' id='csrfmiddlewaretoken' name='csrfmiddlewaretoken' value='123412341234' /></div>
    <div style='display:none;'><input type='hidden' id='csrfmiddlewaretoken' name='csrfmiddlewaretoken' value='123412341234' /></div>
    <input type="hidden" name="key" value="uploads/${filename}">
    <input type="hidden" name="AWSAccessKeyId" value="ASFDFDSF">
    <input type="hidden" name="acl" value="private">
    <input type="hidden" name="success_action_redirect" value="http://localhost/">
    <input type="hidden" name="policy" value="asdhfkajewhlfawe">
    <input type="hidden" name="signature" value="asdfasdfasdf">
    <input type="hidden" name="Content-Type" value="image/jpeg">
    <!-- Include any additional input fields here -->

    File to upload to S3:
    <input name="file" type="file">
    <br>
    <input type="submit" value="Upload File to S3">
</form>

I have tried adding csrfmiddlewaretoken to my policy document, but that does not work. Has anyone ran into this problem and found a solution? I have searched high and low but can not seem to find an answer to this specific problem.

Running Django 1.3.1 for this project if that matters..

  • 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-10T20:05:35+00:00Added an answer on June 10, 2026 at 8:05 pm

    Answering my own question with help from Christopher’s comment.

    Here is my policy document:

    {"expiration": "2014-01-01T00:00:00Z",
    "conditions": [
        {"bucket": "media.somehost.com"},
        ["starts-with", "$key", "uploads/"],
        ["starts-with", "$csrfmiddlewaretoken", ""],
        {"acl": "private"},
        {"success_action_redirect": "http://localhost/"},
        ["starts-with", "$Content-Type", ""],
        ["content-length-range", 0, 1048576]
    ]
    

    I just needed to add the csrfmiddlewaretoken to my policy with the correct format.

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

Sidebar

Related Questions

Im having problem's adding map markers to gmaps using jquery. Here is my code
I have a form on a page: <form id=create_event method=post action={% url app.views.create_event course.id
I'm having some trouble with implementing CSRF protection on a login form. Here is
I am having problem using mvc:resources in spring 3.1 configuration. Initially i was working
I'm having problem with datagrid view. I have attached an image with the code
I am having problem with drawing multiple lines during repaint. The code is as
hello I am having problem related to https:// . I have used FB.getLoginStatus(function(response) function
Having problem with this bit of code qith jQuery. it should pick the values
m having problem in passing parameter to controller action, i have done the following
I am having problem with the title of a header in my jquery code.

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.