We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27716
    • 126 Posts
    Hi Guys,

    Im trying to Implement the below HTML form to s3 upload
    http://aws.amazon.com/articles/Ruby/1434


    In that guide it says you have to sign each upload with the following script. It gives Java, Ruby and Python versions.

    Which would be the easiest to use and how would I go about implementing this in Revo? Not sure how to go about using any of those languages in Modx

    import sun.misc.BASE64Encoder;
    import javax.crypto.Mac;
    import javax.crypto.spec.SecretKeySpec;
    
    String policy = (new BASE64Encoder()).encode(
        policy_document.getBytes("UTF-8")).replaceAll("\n","").replaceAll("\r","");
    
    Mac hmac = Mac.getInstance("HmacSHA1");
    hmac.init(new SecretKeySpec(
        aws_secret_key.getBytes("UTF-8"), "HmacSHA1"));
    String signature = (new BASE64Encoder()).encode(
        hmac.doFinal(policy.getBytes("UTF-8")))
        .replaceAll("\n", "");


    Any Guidance appreciated,

    Stuart
      • 33968
      • 863 Posts
      You’ll need to use php to get it working with modx. However I couldn’t find a tutorial and it seems some key docs are missing from amazon’s web site. It shouldn’t be too difficult to do though.

      Is this any help to you at all:
      https://forums.aws.amazon.com/thread.jspa?messageID=225869

      Ignore the jQuery part but it should give you an idea of what to include in your snippet and how to set up your policy. You can then output the signature and encoded policy to placeholders in your form.
        • 27716
        • 126 Posts
        Hi Lucas,

        Thank you for the link.

        I searched around for PHP based solutions and in the end got this one setup easily
        http://net.tutsplus.com/tutorials/php/how-to-use-amazon-s3-php-to-dynamically-store-and-manage-files-with-ease/comment-page-1/#comments

        Now going to search for a solution with progress bar....

        Stuart
          • 12028
          • 152 Posts
          About the progress bar - had you tried http://www.plupload.com/ ?
            - A small step for mankind, so why not take two...

            Working with web production, graphic design/workflow, photo and education - but are trying to get a life in between!
            • 27716
            • 126 Posts
            Hi Henrik,

            Thanks for the link, looks amazing.

            Will have a shot tomorrow, seems there are also some solutions for s3 direct upload.

            Stuart
            http://www.plupload.com/punbb/viewtopic.php?id=133