|
From: James W. <jw....@gm...> - 2008-07-31 12:21:51
|
I'm having trouble getting the photo to write to disk. I can't see in this
code snippet what might be wrong about how I'm using the rets-client API.
This is from a unit test that I'm using as an "exploration test" to confirm
I'm using the rets-client api correctly against this Rapattoni RETS
service. So you can see from the assert that the RETS service says the
image is a jpeg. Gimp reports that the file "Not a JPEG file: starts with
0xef 0xbf". I've tried Photos from a couple different listings with the
same results. Could someong please confirm that I'm using the
GetObjectResponse correctly?
-James
...snip...
GetObjectResponse objectResponse =
session.getObject(getObjectRequest);
Assert.assertEquals("image/jpeg", objectResponse.getType());
GetObjectIterator getObjectIterator = objectResponse.iterator();
while (getObjectIterator.hasNext()) {
SingleObjectResponse singleObjectResponse =
getObjectIterator.next();
Assert.assertEquals("image/jpeg",
singleObjectResponse.getType());
Assert.assertEquals(resourceEntity,
singleObjectResponse.getContentID());
InputStream inputStream = singleObjectResponse.getInputStream();
BufferedInputStream bis = new BufferedInputStream(inputStream);
File tempFile = File.createTempFile("rets_test_photo", ".jpeg");
FileWriter writer = new FileWriter(tempFile);
int b = -1;
while ((b = bis.read()) != -1) {
writer.write((byte) b);
System.out.print(".");
}
System.out.println();
writer.close();
}
...snip...
|