Disclaimer: I'm about 17mins into Play! so please excuse unforgivable
errors.
I am following up on a tutorial I wrote on how to get started with the
new HTML5 DnD & File API's -
http://www.thebuzzmedia.com/html5-drag-and-drop-and-file-api-tutorial/
- with a Play! application to try and provide an immediate Drag-and-
Drop file upload experience for local files.
The part I'm getting stuck on (and this is where my newness is going
to hang me) is my XMLHttpRequest POST to the repsective Play! action:
---------------------
var client = new XMLHttpRequest();
client.open("POST", "/upload");
client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
client.send(evt.target.result);
---------------------
with a route that looks like:
---------------------
POST /upload
Application.upload
---------------------
and an action that looks like:
---------------------
public static void upload(File upload) {
System.out.println("Uploaded: " + upload);
}
---------------------
The part I'm confused on:
1. Is this even the right way to do this? I'm pretty new to fancy
JavaScript as well.
2. What signature should my upload() method have to grab the uploaded
bytes? I've tried "byte[]" and "File" and "String" -- I'm just not
clear on the binding rules. I want to support uploading binary files
as well as text files... if that is important?
3. One last step I'll need is a redirect after the post to another
Play! page displaying a summary for the upload... I *think* that means
in my upload(..) action calling another action that does a redirect to
another action with the interesting args in it that the template will
render... just want to make sure that is right.
Any help to clear this fog would be appreciated. I searched quite a
bit but "javascript file upload" or "javascript post upload" doesn't
turn up anything and "file upload" turns up umpteen pages.
Thank you.