File promises are kind of a difficult concept to describe, so I decided to explain them using a video. Hopefully this clarifies what file promises are, and why it’s such a cool new feature of AIR 2.0:
Here’s the code that creates a URLFilePromise for every file to be downloaded and puts them on the clipboard. But first, some code context:
onDragStartis the event handler that gets called when the user starts dragging items from the list of objects.bucketListis the ComboBox of bucket names.objectListis the DataGrid of objects.- The function
s3.getTemporaryObjectURL(...)generates a temporary public URL that points to the specified object. It’s the URL that theURLFilePromisewill use to access the file.
private function onDragStart(e:DragEvent):void{if (bucketList.selectedIndex == 0 || objectList.selectedItems == null) return;var c:Clipboard = new Clipboard();var items:Array = objectList.selectedItems;this.filePromises = new Array();for each (var item:Object in items){var fp:URLFilePromise = new URLFilePromise();var req:URLRequest = new URLRequest(s3.getTemporaryObjectURL(bucketList.selectedItem.name, item.key, 60));fp.request = req;fp.relativePath = item.key;this.filePromises.push(fp);}c.setData(ClipboardFormats.FILE_PROMISE_LIST_FORMAT, this.filePromises);NativeDragManager.doDrag(objectList, c, null, null, null);}
Below is the function that gets called when the drop is complete. It’s responsible for opening the ProgressWindow component and passing it the array of URLFilePromise objects which the ProgressWindow component hooks into in order to receive progress events.
private function onDragComplete(e:DragEvent):void{var progressWindow:ProgressWindow = new ProgressWindow();progressWindow.open(false);progressWindow.setFilePromises(this.filePromises);}
The code for S3E is open source and available on Google Code.

ah, ok. now i get what file promises are. thanks for the explanation. is this a common term used, or did you guys make this up?
@Sean: “File Promises” is a term that we got from OS APIs. We didn’t come up with it ourselves. You can read more here (scroll down to the “File Promises” section):http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DragandDrop/Tasks/DraggingFiles.html
Hi Christian,I’m trying to setup S3E but it does not compile because of the missing URLFilePromise class. In which SDK do I find it? I’m using the latest AIR 2.0 beta on Windows.Can’t figure out what I’m doing wrong… An idea?Thanks, Thilo
I am trying to compile the example on URLFilePromise, but my Adobe Flash Builder 4 is not able to resolve the URLFilePromise component/class. Neither adobe.desktop.URLFilePromise nor flash.desktop.URLFilePromise seem to exist. Thanks for any help. I am using Adobe Flash Builder 4 on Mac OS X with Flex SDK 4.0kittu