fluid infusion uploader - postParams and meta info

Colin Clark colin.clark at utoronto.ca
Tue Mar 31 17:27:53 UTC 2009


Aaron,

Awesome feedback. Comments inline...

On 29-Mar-09, at 11:17 PM, Aaron Brown wrote:

> Solutions:
> 1) Add a listener function that triggers on the completion of the  
> batch, causing a separate AJAX request to tell the server about all  
> the files in the batch.  The web app would hold off sending any  
> emails until it gets this special "I'm done! Here's what I just  
> did..." signal.
>
> I avoided this option on the grounds that first, limiting the number  
> of extra AJAX communications is generally good and second, that it  
> might be difficult to tell which files were just sent in this most  
> recent batch if, for example, the user uploaded two files, then  
> added a few more to the existing queue and uploaded them  
> separately.  What is the "batch"?

Yep, that makes sense. Uploader's current conception of a batch is  
just a group of files that were added to the queue and uploaded  
together. After each afterUploadComplete cycle, the batch is reset.

> 2) Set a postParams option on the uploadManager and use that to pass  
> whatever meta data is required.
>
> The problem: postParams, as implemented by the uploadManager, is  
> copied into the underlying swfupload object at the point of  
> instantiation.  At that point, it's too early to know what files are  
> in the queue.  All of my attempts to modify that parameter after the  
> fact failed, though I admit that may be partly because of my  
> unfamiliarity with jQuery and fluid.

You're correct here. At the moment, there's no way to update the  post  
params dynamically. You can set it upon initialization, but can't  
change it afterwards. This is a consequence of how we pass those  
parameters to SWFUpload.

In my mind, this is a bug. I've filed it in our issue tracker. Feel  
free to add to it if I've missed anything.

http://issues.fluidproject.org/browse/FLUID-2428

>
> 3) Use uploadManager listeners to set post_param options directly on  
> the swfupload object.
>
> This is the solution I ended up with.  It works, but it requires  
> diving straight through the uploadManager skin and messing with  
> swfupload directly.  I found that the swfupload.js script includes  
> some interfaces to adjust the post_params later in the game, so I  
> made use of those to send my meta data.  I can provide a more  
> complete code sample if anyone wants it, but here's the important  
> part:

This is exactly the workaround I would have suggested. Looks good.

> The ability to add/reset/modify postParams during the course of the  
> upload sequence seems like it could be really useful.  This is where  
> I think a quick API addition could give a more direct accessor to  
> the methods in swfupload.js that manage post_params (addPostParam,  
> setPostParams, etc.).

This should be a pretty easy fix for Infusion 1.1. Do you think an API  
like this is sufficient, where you can set the contents of the  
postParams object to whatever you need?

uploader.setPostParams(paramsObject)

Or would you prefer methods for adding, removing, and resetting as well?

uploader.addPostParams(paramsObject || Key / Value)
uploader.removePostParams(paramsObject || String)
uploader.resetPostParams()

> Sorry for the long-winded email.  And even more sorry if this issue  
> has been covered before on the list.


No, thanks so much for this bug report. Very helpful, and it was news  
to me.

Colin

---
Colin Clark
Technical Lead, Fluid Project
Adaptive Technology Resource Centre, University of Toronto
http://fluidproject.org




More information about the fluid-work mailing list