Adobe Integrated Runtime (AIR) for JavaScript Developers Pocket Reference

(nextflipdebug5) #1
Networking | 133

// back to us.
socket.flush( );
}

function onSocketData( event )
{
var data = socket.readUTFBytes( socket.bytesAvailable );
air.trace( data ); // Hello Bob
}
</script>

</head>
<body onload="init( )">
</body>
</html>

Uploading a File in the Background


Problem


The application user has created numerous files offline, and
you now want to send those to the server without blocking
the user from doing any additional work.


Solution


The File class in Adobe AIR provides anupload( )method
that is designed specifically for this purpose, without having
to create and manage HTML forms.


Discussion


TheFile.upload( )method can upload files via HTTP/S to a
server for additional processing. The upload takes places just
like a traditional multipart file upload from an HTML form,
but without the need to manipulate forms on the client. The
upload process also takes place asynchronously in the back-
ground, allowing the application to continue processing
without interruption.

Free download pdf