SDK |
Documentation |
JavaSonics ListenUp is no longer for sale.Writing Server Scripts to Receive Uploaded FileListenUp sends the recorded message to the server as a file using an HTTP POST. The URL for the POST is that specified using the "uploadURL" Applet parameter. You can write your own scripts to receive the uploaded file and integrate it with your own web based application. Note that any scripting language may be used on the server including PHP, JSP, ASP, Perl, etc. We have provided sample scripts for some languages in the SDK. These can be found in the test folders. Look, for example, in the "php_test" folder for "handle_upload_simple.php". Upload Server Script Requirements (IMPORTANT)The upload server scripts that you write must meet certain requirements. How you do that will depend on the scripting language that you use. More details will be given in the sections for specific languages.
Format of Uploaded DataThe Recorder Applet uploads its data using an HTTP POST in "multipart/form-data" MIME format. This is the same format that HTML FORMs use. In fact, to the server, ListenUp looks just like a submission from a FORM that includes an uploaded file. This allows one to use standard scripting techniques on the server to receive the file. Rather than duplicate existing documentation, I have included references to some available resources. Simulate ListenUp using a FORMTo help you write your own server scripts, we have provided HTML code that simulates the ListenUp Applet. It contains an HTML FORM that uploads a file. This lets you develop and debug your server scripts without using ListenUp. More information here. Uploaded Audio FileNote: the MIME field name for the uploaded file is "userfile". The uploaded file comes with a name but that is just a suggestion from the client. Your script is free to name the file anything you want. Click here for suggestions for naming files on the server. The content type for Speex files is "audio/x-ogg". The content type for WAV files is "audio/wav". Additional Information Uploaded with the Audio FileThe following variables are uploaded along with the recording.
You can also upload additional information as name/value pairs using hidden text fields. These could include user names, email addresses, etc. Returning a Result from Your Script to ListenUpThe server script can send messages that will be displayed to the user. Any line beginning with the word "SUCCESS" or "ERROR" will be displayed in a label on the Applet. Any other output from the script will be echoed to the Java console by ListenUp for debugging. This return value is required in order for the JavaScript methods setUploadCompletionScript(script) or setUploadFailureScript(script) to be triggered. Integration with a DatabaseYour upload script can interact with a database. You may want to use a database to keep track of uploaded messages. In that case, we recommend placing the recorded message file in a regular folder, and just putting the filename in the database. Sending JavaScript Commands back to the ClientYou can send a JavaScript command from the server to the Applet running on the client. Just output "CALLJS" at the beginning of a line followed by the JavaScript code. You will also need to set mayscript="true" in the Applet tag. For example, to pop up an alert message on the client from a PHP server script: echo "CALLJS alert('Server says Hello using CALLJS');\n"; Continue with Your Server Language
If you are using another scripting language, then look in the documentation for that language of that language for keywords "upload file" and "POST" and "HTML FORM". |