Obex push file problem with file size

2006-08-15
2013-04-15
  • I'm implementing a Obex File Pusher, but i have a problem when the file is big.

    I'm working with the avetana linux version

    This is the code snippet :

    connection = Connector.open((String) url);
    cs = (ClientSession) connection;
                   
    InputStream is = new FileInputStream(file);
    byte filebytes[] = new byte[is.available()];
    is.read(filebytes);
    is.close();               
                   
    HeaderSet hs = cs.createHeaderSet();
    hs.setHeader(HeaderSet.NAME, file.getName());
    hs.setHeader(HeaderSet.TYPE, "image/jpeg");
    hs.setHeader(HeaderSet.LENGTH, new Long(filebytes.length));
                   
    putOperation = cs.put(hs);
                   
    OutputStream outputStream = putOperation.openOutputStream();             
    outputStream.write(filebytes);    
    outputStream.close();

    -------------------------------------
    This works with little files, but with big files it throws :

    java.io.IOException: Connection closed
            at de.avetana.bluetooth.connection.BTConnection.read(BTConnection.java:161)
            at de.avetana.bluetooth.rfcomm.RFCommConnectionImpl.access$200(RFCommConnectionImpl.java:42)
            at de.avetana.bluetooth.rfcomm.RFCommConnectionImpl$MInputStream.read(RFCommConnectionImpl.java:136)
            at de.avetana.bluetooth.obex.OBEXConnection.receiveCommand(OBEXConnection.java:274)
            at de.avetana.bluetooth.obex.OperationImpl$OBEXPutOutputStream.write(OperationImpl.java:239)
            at de.avetana.bluetooth.obex.OperationImpl$OBEXPutOutputStream.write(OperationImpl.java:221)
            at de.avetana.bluetooth.obex.OperationImpl$OBEXPutOutputStream.write(OperationImpl.java:213)
            at ObexPusher.run(ObexPusher.java:53)

     
    • cs = (ClientSession) connection;

      // I simply add this instructions, and all work
      cs.connect(null);