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 8396769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:37:22+00:00 2026-06-09T20:37:22+00:00

I have problems with the s3 post form. I read though http://aws.amazon.com/articles/1434/ I followed

  • 0

I have problems with the s3 post form. I read though http://aws.amazon.com/articles/1434/

I followed the whole tutorial:

import sun.misc.BASE64Encoder;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public class Storage {
    public static String awsAccessKey = "xxxxxxxxxxxxxxx";
    public static String awsSecretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

    static String policy_document = "{\"expiration\": \"2013-01-01T00:00:00Z\","
            + "\"conditions\": ["
            + "{\"bucket\": \"kanta-assets\"},"
            + "[\"starts-with\", \"$key\", \"\"],"
            + "{\"acl\": \"public\"},"
            + "{\"success_action_redirect\": \"http://localhost/\"},"
            + "[\"starts-with\", \"$Content-Type\", \"\"],"
            + "[\"content-length-range\", 0, 1048576]" + "]" + "}";

    public static String getPolicy() throws UnsupportedEncodingException {
        return (new BASE64Encoder()).encode(policy_document.getBytes("UTF-8"))
                .replaceAll("\n", "").replaceAll("\r", "");
    }

    public static String getSignature() throws InvalidKeyException,
            IllegalStateException, NoSuchAlgorithmException,
            UnsupportedEncodingException {
        Mac hmac = Mac.getInstance("HmacSHA1");
        hmac.init(new SecretKeySpec(awsSecretKey.getBytes("UTF-8"), "HmacSHA1"));
        return (new BASE64Encoder()).encode(
                hmac.doFinal(getPolicy().getBytes("UTF-8"))).replaceAll("\n",
                "");

    }

}

and my post form looks like this

<form action="https://kanta-assets.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
      <input type="hidden" name="key" value="uploads/${filename}">
      <input type="hidden" name="AWSAccessKeyId" value="@appconfig.Storage.awsAccessKey"> 
      <input type="hidden" name="acl" value="public"> 
      <input type="hidden" name="success_action_redirect" value="http://localhost/">
      <input type="hidden" name="policy" value="@appconfig.Storage.getPolicy()">
      <input type="hidden" name="signature" value="@appconfig.Storage.getSignature()">
      <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>

If I try to upload an jpeg image I get the following error:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>InvalidArgument</Code>
<Message/>
<ArgumentValue>public</ArgumentValue>
<ArgumentName>x-amz-acl</ArgumentName>
<RequestId>6679060CE7C84FA5</RequestId>
<HostId>
wSIzNZvFDFT7WNnUtBq9UY5WSN1ltN9dHErNk6L3v4ciZCSzwUgzTf1PgaFAJTWD
</HostId>
</Error>

I am pretty sure that my mistake is the key value in the policy "[\"starts-with\", \"$key\", \"\"]," I wasn’t sure what this actually means.

The rule for the object’s key name uses the prefix string “upload/”,
which means that the key value must always start with the upload/
subdirectory path.

  • 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-09T20:37:24+00:00Added an answer on June 9, 2026 at 8:37 pm

    try giving the key as just the file name. (remove upload/)

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

Sidebar

Related Questions

I have problem on my blog: http://osify.com while processing add new post with above
I have something that looks like this: POST /o/oauth2/token HTTP/1.1 Host: accounts.google.com Content-Type: application/x-www-form-urlencoded
The post summarizes problems in using Screen in Mac's terminal when you have the
I'm having problems with understanding how jQuery create headers for ajax post. I have
I have a problem with sending POST http request. It stops on (HttpWebResponse)request.GetResponse() and
I have a custom Http Handler which manipulates HTTP POST and GET. I got
I have some problems with the Form.AutoScaleMode property together with fixed size controls, when
I know that XHTML doesn't support nested form tags and I have already read
I have some html like this <form id=reportform method='post'> <input type='hidden' id='qid' name='qid' value=<?php
I have a form with a read only field for display/submit to the next

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.