Is it possible that I can upload a ByteArray and receive a ProgressEvent on the upload progress?
I have tried:
Using URLLoader, but then I realized that it only shows the progress for the download.
Using FileReference, but then I realized that FileReference.data is read only.
Is there any way I can do this?
The user records with their microphone, and the sound is then uploaded to the server. This is why it's a ByteArray and not a FileReference.
Did a bit of searching around and came on a couple other SO posts that seem to indicate it is not possible. If you're using AIR perhaps you could save the ByteArray to a file using FileStream then load that file into a File object and call upload() on it.
You can to this only via self programming.
make and uploader server side script java for ex. and send the progress percentage via socket
so flash sending file and receiving the progress data via socket.
Related
I am building a simple editor-type application in react-redux, and I want to mimic the operation of downloading and uploading json files for saving and loading data - entirely client side. The server side does not need the data. Local storage may be too small, and it would be nice to provide the user the data in a portable file they could upload on a new machine. Is this even possible, and if so how?
Using a blob file.
You can set the content of a new file which is temp and local, then trigger a click event to download the file.
duplicate answer here and here
I am building a flash application which requires loading of an xml file using URLLoader. While developing application in my local machine with flash professional I can easily load it by
private var myLoader:URLLoader = new URLLoader(new URLRequest("./com/assets/config.xml"));
When I publish the application and click on the html generated and the app loads on browser perfectly.
If I make a server (localhost:1111) that delivers the html file over browser on connect, the html file doesn't load the application (.swf).
While trying to debug it, I found that if I change the myLoader variable as below, the html file loads the swf properly.
private var myLoader:URLLoader = new URLLoader(new URLRequest("http://localhost:1111/com/assets/config.xml"));
I believe the SWF is making another GET request after the html loads on my browser, that is the reason the SWF doesn't work without the change.
Is there any way I can load the xml file in SWF before it gets delivered over browser. This is to avoid another call to the server. I appreciate any help in clarifying my understanding and suggestion for workaround.
If you want to upload your SWF and have users access the configuration XML, you will need to host the XML somewhere reachable by your users. Your local machine (localhost:1111) is not reachable by anyone other than yourself (outside of some unusual hosts tweaking on the user's machine).
When you set up hosting and a web-server to actually serve the file over HTTP, you will need to do a few things:
Set up a crossdomain file on the server to define which hosts are allowed to load your configuration XML.
Amend your application to load data from the server, e.g. new URLRequest('http://your_domain_or_ip/config.xml').
The reason you cannot retain your reference to the XML file as a relative ./com/assets/config.xml is because the SWF will only load files over the local filesystem if it is being viewed as a file in the filesystem vs inside a browser.
When the SWF runs, the URLLoader instance you create will perform a HTTP GET to load your XML file.
If you want to avoid performing additional GET requests to fetch the XML, you will have to compile the configuration into the SWF itself using the [Embed] meta tag.
I recently started using Flash Builder for the first time after developing C++ and C# for a long time.
I am using a FileReference object to upload a file to a server using its upload method. However, on the server-side, I need to receive a X-File-Name header. How can I control which headers are sent through the Flash object in Flex/ActionScript?
I couldn't find any resources about this anywhere. Is it possible?
I am afraid you cannot. The FileReference object is provided out—of—the—box and is not that much configurable.
But you can load the file, create your own sockets and reimplement the protocol with your needs (this is feasable if you don't need a lot of features).
Here is an example of how it works : http://googolflex.com/?p=367
My application asks the user to select files for upload using a FileReference / FileReferenceList. The client then compresses the File data and uses URLLoader to upload the contents of the file.
One problem with the URLLoader is that the progress event does not get triggered for uploads. How do I track the upload progress? I am unable to create a FileReference for the newly compressed ZIP ByteArray.
-- Sri
Given the situation of Flex / Flash APIs, the answer is "not possible"
I'm currently building an AIR file uploader designed to handle multiple and very large files. I've played around with different methods of breaking up file into chunks(100mb) and progressively uploading each so that I can guard agains a failed upload/disconnection etc.
I have managed to break up the file in smaller files which I then write to a scratch area on the disc however I'm finding that the actual process of writing the file is quite slow and chews up a lot of processing power. My UI basically grinds to a halt when its writing. not to mention that I'm effectively doubling the local disc space of every file.
The other method I used was to read into the original file in 100mb chunks and store that data in a byteArray which I can then upload as a POST data using the URLLoader class. Problem is that this way I cant keep track of the upload progress because the ProgressEvent.PROGRESS does not work properly for POST requests.
What I would like to know is if it's possible to read into the file in my 100mb chunks and upload that data without having to create a new file but still using the FileReference.upload() method in order to listen to all the available events that method gives me. Ie. create a File() that is made up of bytes 0 - 100mb of the original file, then call upload() on that new File.
I can post my code for both methods if that helps.
Cheers, much appreciated
I had such problem, but we were solve it in another way, we decided to write an socket connector, which will connect to server (e.g. FTP/HTTP) and write down to socket this ByteArray, and we did it also in chunks around the same size, and the biggest file we had to upload was BlueRay movie around ~150GB.
So I hope you got some interesting ideas from my message, If you'd like it, I could share some piece of code for you.