Incorrect upload progress shown when uploading file to Amazon S3 using SDK and Uploadify


Answers

How would the TransferUtility communicate from the server side back to the swf client? I would assume that the upload from the client to the server would be reflected in the progress bar. Next, the server transfer to S3 would be (much slower than writing to a local file), which wouldn't be reported to the client (swf). That would account for the delay between the upload reaching 100% and then having to wait for the page to respond.

Question

My ASP.NET MVC (C#) application is using Uploadify to upload files to Amazon S3 using the SDK for .NET, but it shows incorrect upload progress.

When I upload a file directly to our server using Uploadify it works fine. However, when I upload a file using Amazon S3 TransferUtility.Upload method, the progress bar shows 100% completion quickly, but I need to wait for a long time to attain Uploadify's onComplete event. My code is shown below.

C# code:

using (transferUtility = new TransferUtility(AWSAccessKey, AWSSecretKey))
{
    try
    {
        TransferUtilityUploadRequest request = new TransferUtilityUploadRequest();

        request.WithBucketName(AWSBucket)
            .WithKey(folderKey)
            .WithTimeout(5 * 60 * 1000)
            .WithInputStream(uploadFileStream);

        request.WithCannedACL(S3CannedACL.PublicRead);

        transferUtility.Upload(request);
    }                
    catch (AmazonS3Exception amazonS3Exception)
    {
        throw amazonS3Exception;
    }
}

JavaScript code:

jQuery(document).ready(function () {
    var allowdfileext='*.doc;*.docx;*.pdf;'
    var extarray=allowdfileext.split(';');

    jQuery('#proposalUploadFile').uploadify({
        'uploader': '/Content/uploadify/uploadify.swf',
        'script': '/File/Upload',
        'folder': '/uploads',
        'buttonImg':'/Content/uploadify/upload-file.jpg',
        'cancelImg': '/Content/uploadify/cancel.png',
        'auto': true,            
        'height': '25',
        'width': '95', 
        'wmode':'transparent',
        'sizeLimit': '20971520',
        'onComplete': fileUploaded,
        'multi': false,
        'scriptData': {
            'saveToFolder': 'Temp',
            'fileextension':'*.doc;*.docx;*.pdf;',
            'subdomain':'qa','saveInLocal':'True'
        },
        'fileExt':'*.doc;*.docx;*.pdf;',
        'fileDesc':'Files (*.doc;*.docx;*.pdf;)',
        'onAllComplete': fileUploadCompleted,
        'onError' : function(event, ID, fileObj, errorObj) {
            var r = '<br />ERROR: ';

            switch(errorObj.info) {
                case 405:
                    r += 'Invalid file type.';
                    break;
                case 406:
                    r += 'Some other error.';
                    break;
                default:
                    r += 'Some other error.';
                    break;
            }       
        }
    });
});

Why isn't the progress bar updating like I'm expecting it to?




Tags