Can the server report to client about it`s progress of transferring a file ?

I need to be able to monitor the progress (and present it to the end-user)
of sending a file from Server to client as the client is unable to monitor the progress.
I`m using Wowza media server (rtmp protocol and java server side) and AS3 flash client.
The reason the AS3 client can`t monitor the progress is that
I suffer from FP-1959 Adobe known bug in a slightly different manner then described on the
adobe web page dedicated to it, here:

The AS3 clients connects to a java module on the server (with NetConnection) and asks
to send it a file. The java module sends the requested file as a bytearray.
The AS3 client recieves, BUT it can not present a progress bar of the transfer as
the AS3 Loader class is not accessible while the transfer lasts.
It becomes accessible only when the file is loaded, as described in the  FP-1959 Adobe known bug page.
I have tried transferring this file with amfphp server instead of the Wowza java rtmp server
but the AS3 client bug remains adamant : It can`t be done neither with listening to progressEvent nor with listening to ENTER_FRAME.

As a result of this obstacle I need a whole new way to monitor progress.
Any idea will be very welcome.
Even a general notion may help.
Perhaps there is a way for the server to monitor the progress of sending the file to the client.
perhaps the server can write the progress to some status file and then the client can read it.
perhaps this progress can be polled somehow.

I attached to this message the java server side script responsible for serving the requested file over rtmp.
Many thanks in advance for your efforts.



import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;

public class ModuleSwfLoader extends ModuleBase {

	public void loadSwf(IClient client, RequestFunction function, AMFDataList params) {
		String swfName = "";
		byte[] fileBytes = null;
		if (getParam(params, PARAM1).getType() == AMFData.DATA_TYPE_STRING) {
			String contentFolder = client.getAppInstance().getStreamStoragePath() + File.separator;
			swfName  = contentFolder + params.getString(PARAM1);
			getLogger().info("swfLocation: " + swfName);
		try {
			if (!swfName .isEmpty()) {
				File swf = new File(swfName);
				if (swf.exists() && swf.canRead() && swf.isFile() && swf.length() < Integer.MAX_VALUE) {
					InputStream in = new FileInputStream(swf);
						int length = (int) swf.length();
						fileBytes = new byte[length];

						int offset = 0;
				        int numRead = 0;
				        while (offset < fileBytes.length && (, offset, fileBytes.length-offset)) >= 0) {
				            offset += numRead;
				        if (offset < fileBytes.length) {
				            throw new IOException("Could not completely read file "+swf.getName());
		} catch (FileNotFoundException e) {
			getLogger().info("file not found");
		} catch (IOException e) {
		sendResult(client, params, AMFDataByteArray.wrap(fileBytes));


Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


 Here is some steps you may do:

1- Ask the server for the size of the file: send a Request to the server giving it the ( File Name ) you need and a certain ( parameter ) , and the server should then pass the size of the file to its client.

# IF you can see the currently available bytes transfered to the client
    2- then you now should be able to display the progress ( received / total-size )

    2- select a chunk size ( say 4KB or whatever you see ) and tell the server to give you a portion of the file ( starting from byte X )  with length (chunk-size ) and so, when you receive that chunk you would be able to display a proper progress information.

Psudo code attached.


Best wishes,


Ahmed Bedier
class MyClass
    int chunkSize ; //in bytes
    int start = 0 ;
    int totalSize ;

    private void getSWFFile( fileName )
         // send a request for the file size.

    private void on_file_size_received()
        // select a chunk size and request all file-chunks from server
        start = 0 
        chunkSize = 4096 ; 
        // request first chunk
        sendChunkRequest (start, chunkSize )

    private void sendChunkRequest ( start, ChunkSize )
        // send request with proper parameters.

    private void on_current_chunk_received()
        // display progress
        int progress = (int)( 100 * ( received / total size ) ) ;

        // if (received != totalSize) 
        //    request the next chunk
        //    file download complete.

Open in new window

foyshAuthor Commented:
Dear Ahmed Bedier.
First of all I`d like to heartily thank you for your reply as well as deeply apologise for the delay in my response. This Delay is partly due to my attempting to understand the implications of you suggestion.
I must say that if I only understand how to put your idea to actual code this would be a truely perfect solution for me.
For this reason I`d like to ask you whether you think this is possible to perform in AS3 for client side. I don`t really know any command in AS3 that asks for only a portion of a bytearray. Or if this is to be done withany other client sdie language, would you specify which, please ?
I`d also like to ask you whether in order to put your idea to action, I should change accordingly the server side Java script which I attached to my original message.

Many thanks for your attention and assistance !
foyshAuthor Commented:
As I could find no EDIT option on the board, I repost the 7th and 8th lines of my previuos message , that contained typo errors:
"really know any command in AS3 that asks for only a portion of a bytearray. Or if this is to be done with any other client side language, would you specify which, please ?"

Sorry and thanks.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.


Hi foysh,

Sorry for my late response.

for : "whether I think this is possible to perform in AS3 for client side."

Answer: I gave you a sudo code as I don't program using AS3.

for: "If you should change accordingly the server side Java script "

Answer: of course you will have to change the server code.

- the ( params ) that you pass to the server in the client Network Request can contain, for example, the ( Start ) byte and ( the  Length in bytes ) of the portion of file you are requesting.

the server then should of an FileInputStream on the file specified, Seek to the start byte, Read the amount of bytes requested if available, and then ( sendResult ) with those bytes read.

and as I have already told you in my first comment, client side code should continue to ask the server for (request) the next number of bytes till it receives all the file.

- and If you wonder from where should the client know the length of the file. the answer lies in the first comment. where I told you that your client can send a request with a parameter added that says to the server : Don't send me the file, just tell me the size of it.

then when server code detects that parameter, it should only read the size of the file and ( sendResult )  that file-size to its client.

I hope all things are clear now.

Best wishes,

Ahmed Bedier.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
foyshAuthor Commented:
Thank you,
Ahmed Bedier, for your assistance, and thanks also for clarifying, your answer has helped me in understanding tha path I should take.
foyshAuthor Commented:
Many thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.