Quick Postscript to PLUpload & S3.
Tonight my partner & I spun up plupload on all 4 major browsers on a total of 8 machines in 2 offices.

this included mac, netbooks, laptops, servers, dell vista boxes, etc.

I am awaiting his results but in main development office as my 10 down/ 100 up dedicated DSL circuit got tapped out PLUpload was the first casualty of war in every instance.

Flajaxian could slow to a crawl as could html5 without dropping files and failing.

PLUpload invariably hits a bump and drops the files.

These are all 80+ meg files. The test is with about 30 gigs worth of files.

My partner who uses comcast in Florida gets much better results as of yesterday but we never tried a full bore upload test using every uploader at once with the same payload.

My experience tells me something is happening inside its inner mechanism making it less fault tolerant than my other 2 uploaders.

Again this is with SSL for whoever may read this and it is going straight to the cloud.

If the next version were more fault tolerant it would be awesome indeed.

However the odds of my customers trying a test like this are very slim indeed but this is the big test I've been waiting months to run.

By the by, using perfmon to monitor network, cpu & physical memory resources reveals that it really all boils down to the connection you are running more than anything. If the connection is blazing with mad bandwidth to spare even a relatively weak machine will get the files uploaded.

And I do believe this is my 30th & last post till the next version.

I really do believe this uploader has massive promise for its next version and I can say after 4 months of relentless direct to S3 due diligence that direct to s3 uploaders are a (well I cannot say it without offending those more sensitive souls) smile)

Peace in the multiverse!

Cary

Hi Davit,

Three months sounds good as my site will not be live for apx. 3-6 months.

Unfortunately, our site won't be available to anyone else to play with until we go into official beta testing in several months sad(

I'll supply a link when we are in beta and you can see how we've implemented PLUpload. Perhaps some of your forum members will even be interested in being beta testers as our site is a generic cloud productivity suite (file storage, and alot of other stuff I cannot talk about smile))

A happy note though, after my final changes our newest test box which is a new dell 64 bit box with a very fast connection had the following results:

excerpts QA #11:

IE - Main and SS succeeded without issue.  All 11 attachments made it into the item and the PLupload window stayed put.

FF and Chrome (tabbed SS) - uploaded perfect but this morning the SS tabs must have reloaded as the tab now showed the main page - indicating a refresh event.  clicking on the paperclip showed all uploads presents

Safari - SS test perfect - upload window still active, all files in

Safari Main - had an error - it timed out.  see snap.  BUT - the PL up window indicated 11/11 uploaded.  click off the error message and the main window showed 10 fles in the att tab container.  click the paper clip to wake it up and the 11th file popped into the attachment tab and all were working fine (needed a refresh for the 11th bad boy)

SO - end result - 66/66 files made it to the items  And the fastest upload completed by 11:11 and the slowest by 11:15 - hows that for consistency.


PS- Each test had 10 3-6 mb music files & 6 100+MB zip files. Thus each test was over 1/2 a gig of direct to S3 uploads.


Thanks again & I look forward to your next release. Hopefully it will "plug & play!"

Cary

Hi Davit,

It's a good joke sir. But I have learned a lot about jquery plugins and many other things.

Here are the final results of an all night upload test with PLUpload Flash.

FireFox 4.0 & 3.6 are not reliable with big or small files. In Mac, Windows Server 2008, & Windows Vista the following occurred.

Vista & 08 Server FF: 2 files uploading 102mb & 193MB.
193MB fails as 2nd file in queue. On Vista it made it 2% and 08 Server 46%.

Same test on Vista/08 succeeded in IE9 on Server 08 & IE8 Vista. Also worth re-mentioning Silverlight works with IE properly on IE. So what is I find quite odd is ever since I began coding Ajax in 2006/2007 IE was usually the culprit with all manner of nasty issues where at the time FF was far superior. Then came Chrome and I also started writing cross-browser/platform sites and got to know Safari. IE became my least loved browser that would make a 200+ hour investments look like a nanosecond. And yet it handles the direct to S3 plupload plugins very well compared to FF.

Further that is unusual as Chrome / Safari use webkit and IE/FF usually seem to be on par when I break down my browser issues. But FF & IE have broken ranks here for sure and FF does not like the plugins.

Further this is my 4th direct to S3 uploader. I also have an html5 direct to s3 upload I spent 200+ hours on, Flajaxian was easily good for 175 hours, and I am currently about to start finishing up integrating the Aurigma direct to S3 uploader.

My uploaders run in floating divs to simulate windows and have to update SQL Server via web services so alot of that time is also spent on integration in all honesty with the larger system.

I say this because Aurigma which uses ActiveX for IE and Java for all other browsers is an interesting case too. Aurigma, I learned chokes on FF for mac in simply rendering itself in a div. On safari mac it flickers and then when floating div is moved it disappears entirely leaving whitespace in its wake.

It turns out this is due to Mac & Java I am told, although I tried to learn Java in 97 and did not like the lack of GUI controls and went to ASP instead, so I am no Java expert. At any rate I say all this because FF now has issues in Mac/Window with PLUpload, and Aurigma uploader.

The HTML5 uploader works perfectly always, and the flajaxian code works perfectly always. The flajaxian code is very old and is not maintained although it is free. I was able to migrate it to .net 4.0 and I had tried to learn flash and modify it but I like Flash coding far less than Java smile)

The flajaxian code however from a Javascript/C#/ and what I could learn in 2 weeks of Flash is very well coded from a best practices/efficiency point of view but again it is years old now in the middle of 2011.

I think the solution is many solutions if you support many browsers, at least until HTML5 File API is supported by IE & Safari.

I hope this all helps someone else. My asp.net code that works is available if people look through my now 28 posts.

So this is it until the next release.

Can you give me an indication when it is to be released as the site I am coding is still 3 months away from completion of development. There's time if it can work in Firefox!

If not I will most like detect FF and then not render the button to launch PLUpload FF but will most likely leave it available in Safari, IE & Chrome.

By the way again, size does not matter with FF. It can happen anywhere in the queue at any size. And in a large queue if it fails on one it can keep going and successfully upload the rest.

I would say whoever could really successfully get multipart uploading with resumability, the way the old napster used to work, would own the S3 cloud which I think now has going on 2 billion items uploaded.

That makes McDonald's look pretty bad considering it's only a few years old.

Sayonara, Buenos Noches, Arrivadurci, Peace & Good Tidings to those who dare to direct upload to S3 and save their EC2 instances from the bottleneck of the millennia!

Cary Abramoff
smile)

Final Post Script: Even with it all sorted out for every 10 files or so I upload one will fail. As this only happens intermittently, with Flash runtime and has never happened in 3 months of testing with Flajaxian, I can only assume that it is not quite as robust for my situation as I had hoped.

Thanks again!

Cary

Hi,

I tracked the problem down. It is a compendium of a few variables but I hope this help someone in the future should they ever encounter a similar issue(s).

First I should say even when things work right Silverlight runtime races through the progress %age from 1% to a very high percentage near 95-99% and then just hovers there with no feedback.

With a 150 meg file it could be stuck at say 97% for 40-90 minutes depending upon your connection.

This ONLY happens in Chrome & Firefox. IE9, perhaps Microsoft created Silverlight runs through the % properly. So where Chrome/FF will race to a very high percentage and then appear to stall, even though perfmon shows the upload is running, a user would easily become confused and frustrated.

So I have made Silverlight my second runtime, i.e. 'Flash, Silverlight' instead of 'Silverlight, Flash' as I had hoped to do to bypass the Flash 2GB limit.

Now as to why it was working in some browsers, sometimes is as follows:

The url: attribute of the plugin.

As mentioned my site is SSL.

As of late I had begun to take all my http: & https: references out & just use "//somedomain/somefile.ext".

This works in IE always & in other browsers sometimes.

Since I was ready to give up it suddenly occurred to me to try it again so I set the dev site to go to https://mybucket.s3.amazonaws.com so I wouldn't have to keep remembering to change http to https when I deploy to QA.

Surprisingly it works when I use https://s3.amazonaws.com/mybucket in my dev site (i.e. non-https) but NOT when I use https://mybucket.s3.amazonaws.com, IN SOME BROWSERS.

Anyway there were other permutations tried, and I test in FF, Chrome, IE, Safari & also on Mac but to make a long story short here's what worked:

For https site url should be: https://mybucket.s3.amazonaws.com but again, this only works properly with Flash in my testing, Silverlight will run up to 97% off the bat. Unless you are in IE.

For dev http://mybucket.s3.amazonaws.com, but again, same SL issue.

I have tried many combinations & was not sure it was the URL as there are many variables in my site including JS intervals, IFrames, webservices for policy signing, etc. so while I may not be 100% certain, right now I have 300 Meg uploads running on 2 windows boxes & a macbook in every browser successfully for past 20 minutes without any sign of an issue.

Perhaps Silverlight & Chrome/FF vis a vis S3 have issues that Flash does not.

I long for the day IE9 & Safari support HTML5 uploads as I have a direct to S3 html5 uploader ready the moment my JS features check registers HTML5Upload=TRUE and then my html5 uploader will automagically work in IE9 & Safari and my plugin troubles will be a thing of the past.

At any rate I have to say all my long nights and days spent to get PLUpload working direct to S3, and with JQuery Themeswitching paid off (if this test I'm running succeeds, which I think it will smile)) and I do like the PLUploader very much.

My only wish is out of the box it could calculate an ETA for completion of the job although all the raw materials are there, I'm just too tired of direct to S3 uploading to write any more code for now smile)

Thanks for a great product and I hope this was my last issue.

smile)

Cary Abramoff, happy to be PLUploading direct to the cloud!

Hi,

After much work & testing to get PLUpload direct to s3 set up I am experiencing a great many failures.

There are no symptoms to be found in Fiddler. It is almost as if no request is sent to S3. This happens without rhyme or reason.

We have tested now on 5 machines in 2 states and the only symptom is the progress will go very quickly from 1% - 100% and then give the exclamation point with an I/O error message.

It is also runtime affected. It almost always fails with silverlight although I get an HTTP 200 to request my client access policy from S3.

It has only worked correctly on one machine for Silverlight using IE9.

The site is SSL enabled if that might make any difference, but the fact it sometimes works on one machine in one browser, then an hour or two later fails, or that switching to flash as the primary runtime will get it working for awhile only to fail again has me baffled.

I use flajaxian so I know it is not Flash as flajaxian performs flawlessly direct to S3.

I had really wanted to use PLUpload and had spent at least 200+ hours getting it to work but I am unable to debug it.

The fact it works sometimes and not others on some machines sometimes and others other times makes it extremely time consuming and frustrating to test as their are no discernible http errors or requests coming out of Fiddler.

I cannot add snapshots here or I would. I am not sure if anyone ever tested this in asp.net c# or from a secure site, but I would say after rigorous coding and testing that this product is not ready for .NET/SSL direct to S3 in my experience.

I can share my source code but other than that I am now prepared to abandon my hopes of using this product unless a solution can be offered.

Thanks very much in advance Davit for reading this.

Best,

Cary

Hi!

Nevermind. I fixed it. The url must be in the bucketname.s3.amazonaws.com format rather than s3.amazonaws.com/bucketname format.

It seems with the latter example it cannot issue the proper GET. All is well and my direct to S3 pluploader is now done.

PS- This is why it works anyway. Amazon S3 has a crossdomain.xml as per link below

http://s3.amazonaws.com/crossdomain.xml

Hi,

I have PLUpload working against my Amazon S3 bucket but tonight I noticed something that looks like a bug, or I am not specifying something correctly.

PLUpload is requesting both CrossDomain & ClientAccessPolicy from s3.amazonaws.com rather than mybucket.s3.amazonaws.com.

Now I found out that s3.amazonaws.com has a crossdomain.xml file in its root so that is why Flash always worked. But silverlight failed for me (this is the first time I tried to make it the runtime of choice).

I need to know how to get PLUpload "GET"ting the xml files required for both SL & Flash out of my bucket.

Here is what the get looks like:


GET /crossdomain.xml HTTP/1.1
Host: s3.amazonaws.com
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3


GET /clientaccesspolicy.xml HTTP/1.1
Host: s3.amazonaws.com
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Thanks very much in advance for your timely attention in this matter. I am under the impression this is supposed to somehow be automatic. My uploads do go to my bucket for Flash so somehow it knows my bucket.

I have not looked at this code for a bit until the problem was reported to me by one of my QA people.

Thanks so much!

Cary

10

(13 replies, posted in General discussion)

Actually overriding the response headers will serve my needs. You can just consider this case closed. Sorry for the novel. smile)

11

(13 replies, posted in General discussion)

Hi,

Perhaps you can help with a new issue.
The content-type in your sample seems to specify one particular type.
For example your sample assumes images are being uploaded.
Flajaxian automatically infers this as this metadata is valuable on downloads
I do know how to override the response headers on presigned url download generation but can you comment on how I can specify it to automagically decipher the file's content type. I tried leaving the content-type out of the policy but I started getting errors again.

I will play some more but ideally I would like to fill in the content-type on the fly like we do for ${filename}

Thanks!!

12

(13 replies, posted in General discussion)

Oh... 1 Suggestion For Silverlight Drag & Drop. Somewhere a while ago I read you guys had trouble implementing silverlight drag/drop and gave up.

I have been using the Telerik silverlight uploader for about a year for non-S3 uploads and it can handle drag and drop in IE, Chrome, FF, Safari and Mac Safari & Firefox.

They might be able to help you.

13

(13 replies, posted in General discussion)

Hi!

Well I figured out a foolproof way to get the policy working and then create my own in C#.

Amazon has an online policy encryption & signing tool.

I took your php and plugged the values into their online template.

Then rather than bother with my policy creation code and signing, etc. I just stuffed the one they generated into Javascript values above the plupload jquery instance.

Works in both Silverlight & Flash.

I am including a working policy and the link. Now I just have to make sure my C# output will match what Amazon creates online. Thus this post comprises an example that future asp.net PLUploader enthusiasts can massage into their own site.

Thanks for creating such a great free upload plugin. The learning curve for those new to Amazon AWS, PLUpload is steep, at least it was for me so I hope this helps ease the curve for somebody in the future. Took me 2 months so far to work out 3 direct to S3 uploaders, (Flajaxian, Aurigma & PLUPLOAD!) They all have strengths and weaknesses but I am proud to add your uploader to our offerings.

Magic Policy created at:

http://s3.amazonaws.com/doc/s3-example- … ample.html

Policy Template:
{
  "expiration": "2012-01-01T12:00:00.000Z",
  "conditions": [
    {"bucket": "Krafty1984" },
    {"acl": "private" },
    ["starts-with", "$key", ""],
    ["starts-with", "$Content-Type", "image/"],
    ["starts-with", "$success_action_status", "201"],
    ["starts-with", "$name", ""],
    ["starts-with", "$Filename", ""],
  ]
}

Best,

Cary

14

(13 replies, posted in General discussion)

Silverlight PLUpload Error. Coincides with Amazon 403 Access denied.

IO Error.
The remote server returned an error: NotFound.

15

(13 replies, posted in General discussion)

Hi,

I wanted to mention that while I am approaching this problem from the 403 error and Amazon's Policy I did get an Error #2038 from PLUpload where the error display occurs.

I found the following link and it discusses Flash issues and scripts and a couple of other non-Amazon reasons this error might occur.

Also before you might consider that I do wish to point out when my bucket is public write I can upload. Further silverlight runtime also fails with 403 but I am trying to leave no stone unturned in my quest to use your beautiful uploader.

Thanks Cary smile)

http://www.judahfrangipane.com/blog/200 … -io-error/

16

(13 replies, posted in General discussion)

No sir. I am awaiting Amazon to get back to me but I am fairly sure that the policy is not being accepted. When I tested with public write on bucket I could upload, when I rely on the proper secure policy I receive the cryptic 403.

Because there is no validator, and your example is in php, even though it appears straightforward, and I can not see the issue, and there are no C# developers anywhere I could google have tried this before me I really do know know what to do next.

Try as I might I cannot add Plupload to my toolbelt. sad(

17

(13 replies, posted in General discussion)

Also getting Error: IO error. Error #2038 from control's UI Interface.

Finally I took another look at my policy versus the S3.php.

I modified as:

string policy = string.Format(@"
            {{ 'expiration': '{0}.000Z',
                'conditions': [
                {{ 'bucket': '{1}' }},                   
                {{ 'acl': '{2}' }},
                [ 'starts-with', '$key', '' ], 
                [ 'starts-with', '$Content-Type', '' ],
                {{ 'success_action_status': '201' }},
                [ 'starts-with', '$name', '' ],
                [ 'starts-with', '$Filename', '' ],
            ]
            }}", expirationDate.ToString("s"), bucket, acl);


In my debugger pre-signing it is:

"\r\n            { 'expiration': '2011-04-06T23:26:50.000Z',\r\n                'conditions': [\r\n                { 'bucket': 'multitask123' },                    \r\n                { 'acl': 'private' },\r\n                [ 'starts-with', '$key', '' ],  \r\n                [ 'starts-with', '$Content-Type', '' ],\r\n                { 'success_action_status': '201' },\r\n                [ 'starts-with', '$name', '' ],\r\n                [ 'starts-with', '$Filename', '' ],\r\n            ]\r\n            }"

18

(13 replies, posted in General discussion)

PPS- I noticed my policy C# method was using a success_action 200 instead of 201. I changed it to 201 but still had the same problem. Thanks!

19

(13 replies, posted in General discussion)

PS- If you get this working for me you now have a working C# template for all your asp.net friends in the multiverse: FREE OF CHARGE smile)

Thanks again sir!

Cary

20

(13 replies, posted in General discussion)

Hi Davit!

Since my last attempt to perform direct to S3 uploads with PLUpload I have garnered a bit more experience with all things S3.

The past few days I have been working on using PLUpload to perform direct to S3 uploads with the Flash,Silverlight runtimes.

I believe I am almost there but unfortunately I am receiving "Access Denied" responses from Amazon S3.

I also use Flajaxian Flash direct to S3 uploader in the same site I'm developing and those requests are successful and Amazon S3 returns HTTP 204 errors.

I figured out how to translate your S3.PHP example to C# & I believe I am doing everything correctly.

To keep the issue simple I believe we should just focus on it from the flash perspective, although I do have both crossdomain.xml & clientaccesspolicy.xml properly uploaded and readable in my target bucket.

The successful flajaxian flash direct to s3 upload request from fiddler is just about identical to the PLUpload request in terms of what I would expect except the PLUpload content length is a bit smaller when I experiment with the same file for uploading.

At any rate I am going to include the PLUpload request & response from fiddler followed by the Flajaxian request & response.

I will follow that with my source code for the plupload implementation I am trying to get working.

Hopefully you can help me get over this hump as I feel I am 99.9% there except for the dreaded x-factor that is blocking me.

In the meantime I will open a support ticket with Amazon premium support to see if they can look on their side as I have the ETAG marker which should allow them to possibly comment on what the issue might be.

Thanks very much as always Davit.

Best,

Cary



PLUPLOAD
Failure with 403 access denied... sad(

POST / HTTP/1.1
Accept: text/*
Content-Type: multipart/form-data; boundary=----------KM7Ij5Ij5gL6ei4gL6KM7Ef1Ef1GI3
User-Agent: Shockwave Flash
Host: multitask123.s3.amazonaws.com
Content-Length: 10986
Connection: Keep-Alive
Pragma: no-cache


RESP:
HTTP/1.1 403 Forbidden
x-amz-request-id: DAE0C93411C8F994
x-amz-id-2: 6HSY2CDY4fBDTwqLC37+900v0JxAwECn6P+lP2jCarL2uqCS4DJHgA+VEPV0W2Hm
Content-Type: application/xml
Date: Thu, 07 Apr 2011 00:21:35 GMT
Connection: close
Server: AmazonS3
Content-Length: 231

Flajaxian works:

Success!

POST / HTTP/1.1
Accept: text/*
Content-Type: multipart/form-data; boundary=----------Ij5GI3ei4KM7GI3gL6Ij5Ij5Ef1ei4
User-Agent: Shockwave Flash
Host: multitask123.s3.amazonaws.com
Content-Length: 11980
Connection: Keep-Alive
Pragma: no-cache

response

HTTP/1.1 204 No Content
x-amz-id-2: uiSijP2mCiIh00v9j4Zt1722cMNSV1tKUizoTns0IjSgEhCp7B6oKaiGQN7TWIj9
x-amz-request-id: C9A2E1087DCAD8BF
Date: Thu, 07 Apr 2011 00:17:36 GMT
ETag: "1d7d261909c9709fbf252d3ed7542503"
Location: http://multitask123.s3.amazonaws.com/17 … nzamos.jpg
Server: AmazonS3


.... What follows is my source code (aspx/c#), I understand you guys are mostly not C# but it should be relatively easy to follow as I based it all on your S3.php file.

plup.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="plup.aspx.cs" Inherits="plup" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1 … tional.dtd">
<html>
<head>
    <title>MultiTask123 Stylin' Multi-Select Uploads</title>
    <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css"
        type="text/css" />
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
    <link rel="stylesheet" href="css/jquery.ui.plupload.css" type="text/css" />
    <script src="Themeswitcher.js" type="text/javascript"></script>
    <script runat="server" type="text/C#">
     
           
    </script>

</head>
<body id="top">
    <script src="js/plupload.full.min.js" type="text/javascript"></script>
    <script src="js/jquery.plupload.queue.min.js" type="text/javascript"></script>
    <script src="js/jquery.ui.plupload.min.js" type="text/javascript"></script>
    <script src="js/plupload.flash.min.js" type="text/javascript"></script>
    <script src="js/plupload.silverlight.min.js" type="text/javascript"></script>
    <h5>
        Note: This is NOT a drag & drop zone. You must use the, "Add Files" button. Peace!</h5>
    <script type="text/javascript">
        var ruckus = $('#ruckus').val();
        var spakus = $('#spakus').val();
       
        var allstate = $('#allstate').val();
        var ucicomicsclub = $('#ucicomicsclub').val();
       
        // Convert divs to queue widgets when the DOM is ready
        $(function () {
            $("#uploader").plupload({
                runtimes: 'flash,silverlight',
                url: 'http://multitask123.s3.amazonaws.com/',
                max_file_size: '100000000mb',
                multipart: true,
                multipart_params: {
                    'key': '${filename}', // use filename as a key
                    'Filename': '${filename}', // adding this to keep consistency across the runtimes
                    'acl': 'private',
                    'Content-Type': 'image/jpeg',
                    'success_action_status': '201',
                    'AWSAccessKeyId': spakus,
                    'policy': allstate,
                    'signature': ucicomicsclub
                },

                // optional, but better be specified directly
                file_data_name: 'file',

                // re-use widget (not related to S3, but to Plupload UI Widget)
                multiple_queues: true,



                // Flash settings
                flash_swf_url: '../js/plupload.flash.swf',

                // Silverlight settings
                silverlight_xap_url: '../js/plupload.silverlight.xap'
            });
        });
    </script>
    <div id="main">
   
        <div class="center_wrapper">
            <div id="main_content">
                <form runat="server">
                <input type="hidden" id="ruckus" runat="server" />
                <input type="hidden" id="spakus" runat="server" />
                <input type="hidden" id="allstate" runat="server" />
                <input type="hidden" id="ucicomicsclub" runat="server" />
             
                <div id="uploader" style="height: 330px;">
                    <p>
                        You browser doesn't have Flash or Silverlight support.</p>
                </div>
                <br style="clear: both" />
                <input type="submit" value="Send" />
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="Themeswitcher.js"></script>
    <script type="text/javascript">
        function isIE() {
            if (navigator.appName == "Microsoft Internet Explorer") {
                return true;
            }
            else {
                return false;
            }
        }
        if (!isIE()) {
            $.fn.themeswitcher && $('<div id="switcher" style="padding-bottom:22px;background-color:transparent;"></div>').css({
                position: "absolute",
                right: 10,
                buttonHeight: 50,
                height: 250,
                top: 7
            }).appendTo('#main_content').themeswitcher({ cookieName: 'hero', buttonHeight: 20, width: 250, buttonPreText: 'Krafty likes: ', initialText: 'Theme Menu (Styles Galore!)' });
        }
        else {
            //alert('Reminder to krafty: Add HTML5 Test instead of IE Test. You have item Detect HTML 5 Features in your account');
            alert('Reminder to krafty: Add HTML5 Test instead of IE Test. You have item Detect HTML 5 Features in your account\n\nThis uploader is HTML5 based & not supported by Internet Explorer. Please try the Flajaxian or Aurigma uploaders.\nAlthough it will display it will not work in IE.\nIt will work in latest Chrome, Firefox & Safari.');
        }

   
    </script>
</body>
</html>


C# Code behind for policy signing


using System;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class plup : System.Web.UI.Page
{

   
    protected string ConstructPolicy(string bucket, DateTime expirationDate, string acl, string key)
    {
        // See about policy construction
        // http://docs.amazonwebservices.com/Amazo … ructPolicy   

        string policy = string.Format(@"
            {{ 'expiration': '{0}.000Z',
                'conditions': [
                    {{ 'acl': '{1}' }},
                    {{ 'bucket': '{2}' }},
                    {{ 'success_action_status': '200' }},
                    [ 'starts-with', '$key', '' ],
                    [ 'starts-with', '$Content-Type', '' ],
                ]
            }}", expirationDate.ToString("s"), acl, bucket);

        // Encode the policy using UTF-8.
        byte[] pb = System.Text.Encoding.UTF8.GetBytes(policy.ToString());

        // Encode those UTF-8 bytes using Base64 and return.
        return Convert.ToBase64String(pb);
    }
    public static string CreateSignature(string UnsignedPolicy, string AWSSecretKey)
    {
        string retVal = string.Empty;
        HMACSHA1 sigHash = new HMACSHA1(System.Text.Encoding.UTF8.GetBytes(AWSSecretKey));
        byte[] bytPolicy = System.Text.Encoding.UTF8.GetBytes(UnsignedPolicy);
        byte[] bytSignature = sigHash.ComputeHash(bytPolicy);
        retVal = Convert.ToBase64String(bytSignature);

        return retVal;
    }
    protected string CreateSignature2(string policy, string secretAccessKey)
    {
        // Sign the policy with your Secret Access Key using HMAC SHA-1.
        System.Security.Cryptography.HMACSHA1 hmac = new System.Security.Cryptography.HMACSHA1();
        hmac.Key = System.Text.Encoding.UTF8.GetBytes(secretAccessKey);

        byte[] signb = hmac.ComputeHash(System.Text.Encoding.UTF8.GetBytes(policy));

        // Encode the SHA-1 signature using Base64.
        return Convert.ToBase64String(signb);
    }

     
    protected override void OnPreRender(EventArgs e)
    {
        string bucket = System.Configuration.ConfigurationSettings.AppSettings["AmazonS3_Bucket"].ToString();
        string accessKeyId = System.Configuration.ConfigurationSettings.AppSettings["AmazonS3_AWSAccessKeyId"].ToString();
        string secret = System.Configuration.ConfigurationSettings.AppSettings["AmazonS3_SecretAccessKey"].ToString();
        string policy = ConstructPolicy(bucket, DateTime.Now.Add(new TimeSpan(0, 0, 0, 45)), "private", accessKeyId);
        string signature = CreateSignature(policy, secret);
        this.ruckus.Value = bucket;
        this.spakus.Value = accessKeyId;
        this.allstate.Value = policy;
        this.ucicomicsclub.Value = signature;

       
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

Thanks again sir! Spasiba!

Cary

I understand completely Davit. I am experimenting with outsourcing this job and this thread might help jquery/php experts to avoid having to merge the jquery-html5-uploader code with your html5 script. At any rate it has been educational and you always respond quickly! Thanks again sir!

Hi Davit,

I am afraid my understanding, as explained of PHP is non-existent. I see that my ignorance is php is something that you cannot walk me through. I appreciate you taking the time to respond to my posts.

However, I do think if it were a case of it being simple as you say, in other words it should just work as is, you would be able to create a sample in no time at all.

I am sure this could only reflect well on your product smile

But I see I will regrettably have to abandon my PLUpload plans for now.

Thanks anyway sir. I appreciate all your efforts!

Best,

Cary

Hi Davit,

Interesting results. I created a new bucket for this new experiment.
I put the php, html, and all support files therein.

The uploader loads just fine.

I drag and bunch of images onto the uploader and then click start upload.

The progress bar jumps into action and it accurately loops through the files and shows the total size. Perhaps it goes too fast... Just not sure what I should be looking for here.

I then click a button <input type="submit" value="Here goes nothin!"/>


The browser URL changes to the correct address of the s3.php so I think my paths are fine.

Fiddler shows and http 405 error as per (which is also rendered with the s3.php):

<Error>
<Code>MethodNotAllowed</Code>

<Message>
The specified method is not allowed against this resource.
</Message>
<ResourceType>OBJECT</ResourceType>
<Method>POST</Method>
<RequestId>AA599DD8D364C1DB</RequestId>

<HostId>
eAgROVNQ3AoHwr6Qmr9u9JnmccjLtxD49oESITcKh75PgahpjVJdqd2XfLrSMttp
</HostId>
</Error>


Due to my unfamiliarity with PHP and this process I am relying upon your expertise.

I am including my html & php pages below to hopefully determine whether or not this is truly possible. I am stuck and do not understand whether what I am trying to do is possible. Fiddler does seem to register all the files I want to upload it's just this 405 error which seems to imply it will not allow the post.

Also the inside of the s3.php PLUpload supplies seems geared towards the silverlight/flash cross domain methodology so... well I am just not sure what is going on and if I am missing something or this is just not allowed... smile

I appreciate all your help Davit!

Thanks,

Cary


HTML Page with uploader on it:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1 … tional.dtd">


<html>



<head>


    <title>MultiTask123 Stylin' Multi-Select Uploads</title>

    <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>

    <link rel="stylesheet" href="css/jquery.ui.plupload.css" type="text/css" />

    <script src="Themeswitcher.js" type="text/javascript"></script>
    </head>

<body id="top">

<!-- Thirdparty intialization scripts, needed for the Google Gears and BrowserPlus runtimes -->

  <script src="jsdev/plupload.js" type="text/javascript"></script>
    <script src="jsdev/jquery.plupload.queue.js" type="text/javascript"></script>
    <script src="jsdev/jquery.ui.plupload.js" type="text/javascript"></script>
    <script src="jsdev/plupload.html5.js" type="text/javascript"></script>

<script type="text/javascript">

// Convert divs to queue widgets when the DOM is ready
$(function() {
    $("#uploader").plupload({
        runtimes : 'html5',
        url : 'http://<?php echo $bucket; ?>.s3.amazonaws.com/s3.php',
        max_file_size : '10mb',
       
        multipart: true,
        multipart_params: {
            'key': '${filename}', // use filename as a key
            'Filename': '${filename}', // adding this to keep consistency across the runtimes
            'acl': 'public-read',
            'success_action_status': '201',
            'AWSAccessKeyId' : '<?php echo $accessKeyId; ?>',       
            'policy': '<?php echo $policy; ?>',
            'signature': '<?php echo $signature; ?>'
        },
       
        // !!!Important!!!
        // this is not recommended with S3, since it will force Flash runtime into the mode, with no progress indication
        //resize : {width : 800, height : 600, quality : 60},  // Resize images on clientside, if possible
       
        // optional, but better be specified directly
        file_data_name: 'file',
       
        // re-use widget (not related to S3, but to Plupload UI Widget)
        multiple_queues: true,

        // Specify what files to browse for
        filters : [
            {title : "JPEG files", extensions : "jpg"}
        ]
    });
});

</script>       
<script type="text/javascript">
    // Convert divs to queue widgets when the DOM is ready

    $(function () {
   
        $("#uploader").plupload({
            // General settings
            runtimes: 'html5',
            max_file_size: '20000mb',

        });

        // Client side form validation
        $('form').submit(function (e) {
            var uploader = $('#uploader').pluploadQueue();

            // Validate number of uploaded files
            if (uploader.total.uploaded == 0) {
                // Files in queue upload them first
                if (uploader.files.length > 0) {
                    // When all files are uploaded submit form
                    uploader.bind('UploadProgress', function () {
                        if (uploader.total.uploaded == uploader.files.length)
                            $('form').submit();
                    });

                    uploader.start();
                } else
                    alert('You must at least upload one file.');

                e.preventDefault();
            }
        });
    });

</script>



<div id="main">

    <div class="center_wrapper">

        <div id="main_content">

           
            <form method="post" action="s3.php">

                <input type="submit" value="YEAH RIGHT!" />
                <div id="uploader" style="height: 330px;">

                    <p>You browser doesn't have HTML5 support. Please try our Flash or Aurigma uploader. We've got lots of sizes in stock! Cuz M3 Rocks!</p>

                </div>

            </form>


        </div>

    </div>

</div>



<script type="text/javascript" src="Themeswitcher.js"></script>

<script type="text/javascript">
    function isIE() {
        if (navigator.appName == "Microsoft Internet Explorer") {
            return true;
        }
        else {
            return false;
        }
    }
    if (!isIE()) {
        $.fn.themeswitcher && $('<div></div>').css({
            position: "absolute",
            right: 10,
            top: 10
        }).appendTo('#main_content').themeswitcher({ cookieName: 'hero' });
    }
    else {
        //alert('Reminder to krafty: Add HTML5 Test instead of IE Test. You have item Detect HTML 5 Features in your account');
        alert('Reminder to krafty: Add HTML5 Test instead of IE Test. You have item Detect HTML 5 Features in your account\n\nThis uploader is HTML5 based & not supported by Internet Explorer. Please try the Flajaxian or Aurigma uploaders.\nAlthough it will display it will not work in IE.\nIt will work in latest Chrome, Firefox & Safari.');
    }
   
</script>


</body>

</html>

////////////////////////////
PHP BELOW DAVIT.. smile
///////////////////////////

<?php
$bucket = 'SampleForPLPUploaderForum';

// these can be found on your Account page, under Security Credentials > Access Keys
$accessKeyId = 'SampleForPLPUploaderForum';
$secret = 'SampleForPLPUploaderForum';


// hash_hmac — Generate a keyed hash value using the HMAC method
// (PHP 5 >= 5.1.2, PECL hash >= 1.1)
if (!function_exists('hash_hmac')) :
// based on: http://www.php.net/manual/en/function.sha1.php#39492
function hash_hmac($algo, $data, $key, $raw_output = false)
{
$blocksize = 64;
if (strlen($key) > $blocksize)
$key = pack('H*', $algo($key));

$key = str_pad($key, $blocksize, chr(0x00));
$ipad = str_repeat(chr(0x36), $blocksize);
$opad = str_repeat(chr(0x5c), $blocksize);
$hmac = pack('H*', $algo(($key^$opad) . pack('H*', $algo(($key^$ipad) . $data))));

return $raw_output ? $hmac : bin2hex($hmac);
}
endif;

// prepare policy
$policy = base64_encode(json_encode(array(
// ISO 8601 - date('c'); generates uncompatible date, so better do it manually
'expiration' => date('Y-m-d\TH:i:s.000\Z', strtotime('+1 day')),
'conditions' => array(
array('bucket' => $bucket),
array('acl' => 'public-read'),
array('starts-with', '$key', ''),
// for demo purposes we are accepting only images
array('starts-with', '$Content-Type', 'image/'),
// "Some versions of the Adobe Flash Player do not properly handle HTTP responses that have an empty body.
// To configure POST to return a response that does not have an empty body, set success_action_status to 201.
// When set, Amazon S3 returns an XML document with a 201 status code."
// http://docs.amazonwebservices.com/Amazo … Flash.html
array('success_action_status' => '201'),
// Plupload internally adds name field, so we need to mention it here
array('starts-with', '$name', ''),
// One more field to take into account: Filename - gets silently sent by FileReference.upload() in Flash
// http://docs.amazonwebservices.com/Amazo … Flash.html
array('starts-with', '$Filename', ''),
)
)));

// sign policy
$signature = base64_encode(hash_hmac('sha1', $policy, $secret, true));

?>

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Plupload to Amazon S3 Example</title>

<!-- jQuery and jQuery UI -->
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src=" https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>

<!-- Load plupload and all it's runtimes and finally the UI widget -->
<link rel="stylesheet" href="css/jquery.ui.plupload.css" type="text/css" />
<script type="text/javascript" src="../js/plupload.full.min.js"></script>
<script type="text/javascript" src="../js/jquery.ui.plupload.min.js"></script>
<!--<script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>-->

</head>
<body>


</body>
</html>

Hi Davit!!

Thanks for all your assistance. I am going to do my level best to try out your suggestions right now. I did not think I could run a php file out of S3. My php experience is on par with my astronaut experience wink)

As to the post versus put with jquery-html5-upload plugin....

It is indeed using put.

Here is the thread and below is my implementation which actually works smile)

While tracing I also noticed the default of POST but I believe the thing to keep in mind here is that it was not originally designed to work with S3. That is a recent development and the individual who retrofitted it for S3 implemented it via PUT as per.....

http://code.google.com/p/jquery-html5-u … tail?id=12

Excerpt:

DMagon: yes, I have it working on S3, you can see a sample at http://upload.attik.com/html5_upload/example.html

If you look at the source, you can see how I've set things to work, including setting the **method to PUT** and sendBoundary to false (if you send boundaries they will be in the file).
S3 settings: you need to put these files in a bucket that has public-write access. Of course if you set both public write and public read, anyone can use your S3 bucket for their own file storage, so I would discourage that.
NOTE: I plan to submit a patch to allow more flexibility in the headers sent. I have added a header at line 124 (x-amz-acl: bucket-owner-full-control) that gives the bucket owner full control over the file. Sometimes AWS can lock you out of doing anything with the file but deleting it if you don't do this.

Implementation: notice 'PUT' for method attribute value. I believe this is required for progress bar to function....

<script type="text/javascript">
            //this is html5 upload control
            // debugger;

            $("#upload_field").html5_upload({
                autostart: false,
                method: 'PUT',
                STATUSES: {
                    'STARTED': 'Started',
                    'PROGRESS': 'Progress',
                    'LOADED': 'Loaded',
                    'FINISHED': 'Finished'
                },
                headers: {
                    'x-amz-acl': 'bucket-owner-full-control',
                    'Content-Type': function (file) {
                        var ext = file.fileName.split(".").pop();
                        switch (ext) {
                            case 'htm':
                            case 'html':
                            case 'htmls':
                                return 'text/html';
                            case 'css':
                                return 'text/css';
                            case 'gif':
                                return 'image/gif';
                            case 'jpeg':
                            case 'jpg':
                                return 'image/jpeg';
                            case 'png':
                                return 'image/png';
                            case 'pdf':
                                return 'application/pdf';
                            case 'zip':
                                return 'application/zip';
                            default:
                                return 'application/octet-stream';
                        }
                        return ('application/octet-stream');
                    }
                },
                genName: function (file, number, total) {
                    return file + "(" + (number + 1) + " of " + total + ")";
                },
                url: function (number) {
                    return 'testing/' + $('#upload_field')[0].files[number].fileName;
                },
                sendBoundary: false,
                setName: function (text) {
                    $("#progress_report_name").text(text);
                },
                setStatus: function (text) {
                    $("#progress_report_status").text(text);
                },
                setProgress: function (val) {
                    $("#progress_report_bar").css('width', Math.ceil(val * 100) + "%");
                },
                onFinishOne: function (event, response, name, number, total) {
                    //       alert('test onFinishOne');
                }
            });
        </script>


Thanks Davit,

I will attempt to follow your instructions and let you know if I am successful or otherwise....

Best,

Cary smile)

I just reread this entire thread as I know I am missing something profound yet simple; the horror! smile)

However I just want to clarify that the jquery-html5-plugin does indeed use 'PUT", and does indeed have progress....

I believe this could revolutionize the PLUpload control in the cloud.... And we see now, more than ever, the cloud is the end all and be all; it is the future!

Help smile)

Thanks Again!

Cary