0

I need to upload file on server through flex GUI which send file on server with using rtmps protocol.

I tried to send on server just FileReference and request has performed, but on server side i got only empty ObjectMap. I know that I can user URLRequest, but I need exactly rtmps request.

My Flex code:

public function uploadFile(file:FileReference):void{
     NetConnection nc = new NetConnection();
     nc.client = this;
     nc.proxyType = "best"; 
     nc.connect(connectionURL, "3.0", "userName", "password");
     nc.call("uploadFile", null, file);
}

My Java code:

public void uploadFile(Object param) { // <-- param is empty ObjectMap
    log.info("Upload file.");
    // save file on server
}

Can anyone help me?

Vartlok
  • 2,539
  • 3
  • 32
  • 46

1 Answers1

1

Java doesn't know how to map the FileReference class to a java equivalent. In flex, get the ByteArray from the FileReference and send that to the server. Java knows how to deal with a byte array. You can do with it on the server as you please then.

  • Do you mean file.data? If so, I'm tring this way right now, and found one problem, that Java get class org.red5.io.amf3.ByteArray and i don't know how to convert it in something that i can write in file. – Vartlok Apr 16 '14 at 13:13
  • in your java function change the param type to byte[] and not Object. – Robin van den Bogaard Apr 17 '14 at 07:33
  • I found another solution http://stackoverflow.com/questions/23126842/convert-flex-bytearray-in-java-byte, but thank you for answer, it helpful. – Vartlok Apr 17 '14 at 08:20