The docs say there must be some PutAs() function that sets an individual stream of a container. A container in FM has multiple streams; it seems that by default it sets the 'FILE' stream with data. Try to also set the 'FNAM' stream with a string. I.e. as far as I understand it must be like:
INSERT INTO table (PutAs( container, 'FILE' ), PutAs( container, 'FNAM' )) values (?, ?)
which is then bound to parameters: file data stream and a string. Actually, I'm not sure if the latter must be a string (unicode) or a also a raw byte stream, but let's start with a string :)
Thanks for the prompt reply.I cant seem to find any documentation with the 'FNAM' stream. I have tried to do an update since the time I saw your post and have failed miserably.
This does not work:
String sql = "UPDATE TestTable SET (PutAs( Results, 'FILE' ) = ?, PutAs( Results, 'FNAM' ) = ?) WHERE \"SampleId\" ='1234'";
This works but gives me an untitled.jpg though I have tried setting the second parameter to a String and a InputStream but failed.
String sql = "UPDATE TestTable SET Results = PutAs(?, 'JPEG '), Results= PutAs(?,'FNAM') WHERE \"SampleId\" ='1234'";
This is how I am converting my String to an inputStream.Is this the problem?
InputStream is = new ByteArrayInputStream( myString.getBytes() );
Well, from what I see FileMaker uses VERY strange encoding on the FNAM stream. Could you try to set the 'FNAM' stream to the following string:
(The end dot is a part of the string.) This is how it looks in Python; the \xNN indicate individal byte codes, i.e. the first three bytes are zero, then one, then four and so on. Individual characters go as they are. The four characters at the end (BTW, the \x04 before seems to be the length of the string) are actually "test". You can see that "t" is mapped to a dot "." in both places. But I don't quite see why they're mapped this way.
If this works, I can produce a full encoding table.