Hello, I am trying to develop an app that downloads a file from a Bluetooth FTP server. If I use this code to dowload a file-list works fine, but if I use the same code to download a real file it doesn't. I have tried with text plain, image, video (mp4 and 3gp) and audio with the same result. If I install my app in a Nokia (N95) or a Motorola (K3) works perfect, but I can't make it work on my Blackberry 8310
This is the code to get the InputStream:
PHP Code:
public InputStream getFileInputStream(ClientSession conn, Operation op, String stFile, String stType) throws IOException {
InputStream inputStream = null;
bytexxx91;xxx93; FBUUID = {(byte) 0xF9, (byte) 0xEC, (byte) 0x7B, (byte) 0xC4, (byte) 0x95,
(byte) 0x3C, (byte) 0x11, (byte) 0xD2, (byte) 0x98, (byte) 0x4E, (byte) 0x52, (byte) 0x54,
(byte) 0x00, (byte) 0xDC, (byte) 0x9E, (byte) 0x09 };
String file = stFile;
String type = stType;
if (file==null) file="";
if (type==null) type="";
//Prepare the headers for the OBEX commands
HeaderSet header = conn.createHeaderSet();
header.setHeader(HeaderSet.TARGET, FBUUID);
//Send OBEX Connect
HeaderSet response = conn.connect(header);
//In order to go the desired folder the OBEX SETPATH command is beeing used
//Prepare the header for the SETPATH commad
header = conn.createHeaderSet();
//folder_name is set to the name of the desired folder
//if left blank the root folder will be used
String folder_name = "";
header.setHeader(HeaderSet.NAME, folder_name);
//Send the SETPATH command
HeaderSet result = conn.setPath(header, false, false);
//Prepare the header for the GET command
header = conn.createHeaderSet();
header.setHeader(HeaderSet.NAME, file);
header.setHeader(HeaderSet.TYPE, type);
op = conn.get(header);
//The selected file will be send to the operation's input stream
inputStream = op.openInputStream();
return inputStream;
}
And the call:
PHP Code:
InputStream in = getFileInputStream(conn, op, "text.txt", "text/plain");
The same call that works perfect for file-list (in BlackBerry too):
PHP Code:
InputStream in = getFileInputStream(conn, op, "", "x-obex/folder-listing");
This call produces an xml file that can be read perfectly by any phone.
I forgot to say that the problem in the BlackBerry is an EOFException while reading the first byte, no -1 is returned to indicate the end of file but an EOFException.
Any help is much appreciated!
Regards