How to modify FileReference.data before upload
Hi, I'm trying to build a simple image uploader that will allow a user to select a local file, I then need to modify the image and then upload to S3. I'm using FileReference.load() to successfully load the image, turn it in to a Bitmap and back to a ByteArray, but when I try and set the data property of FileReference the original (unedited) file is uploaded. It seems that calling FileReference.upload() ignores the data in the FileReference.data and loads it fresh from the hard drive and posts it off to the server. Is that correct?
In this really simple example I'm not even setting the bytearray to anything new, just clearing it - I would expect it to upload a 0 bytes file or something, but instead it uploads the original file. Is this a bug, am I doing something wrong, or is this correct behaviour?
--
// load the file in to memory
_fileReference.load();
// ... on file reference loaded
trace(_fileReference.data.length); // 230189
_fileReference.data.clear();
trace(_fileReference.data.length); // 0
// With or without this next line it happily uploads the original file (with it commented out I would expect a 0 bytes file, or an error or something)
//_fileReference.data.writeBytes(myNewByteArray);
_fileReference.upload(myURLRequest);
--
Any thoughts greatly appreciated!
Simon