I finally got it. There was nothing wrong with what I was doing at all, but the file I was using was a corrupted file. Out of all of the files I could have picked to test with, I picked the bad one. Go figure. Anyway, it now works. If anyone is wandering here is some sample code:
std::string me = "blobStream"; pqxx::work w(*atr->getConn(),me); pqxx::ilostream s(w, 137396407); ofstream file("test2.seqb", ofstream::binary|ios::trunc); long size; char * buffer(0); cout << "Streaming blob into a file " << endl; if(s.good()) { s.seekg (0, pqxx::ilostream::end); //position stream pointer to end of stream size = s.tellg(); //use this to get the size cout << "SIZE OF LOSTREAM " << size << endl; s.seekg(0, pqxx::ilostream::beg); //reposition back to beginning buffer = new char [size]; s.read (buffer, size); file.write(buffer,size); delete[] buffer; file.close(); } Jeroen T. Vermeulen wrote: > On Thu, September 6, 2007 05:44, Shannon Allen wrote: > >> Update: >> >> Getting closer. I can now get the size of the lostream and it matches >> the size of the file before I put it into the BLOB. The problem I'm >> having now is when I go to write the lostream back out to a file, in >> Linux whenever I do a cmp originalfile newfile, it says that they are >> different ("differ: byte 2590721, line 35"). But the sizes match >> exactly. Anyone have any idea?? >> > > Hmm... Unwanted encoding conversion maybe? This stuff has long been > flushed out of my mental cache, but maybe the LO stream classes need to > add an ios::binary option somewhere. :-/ > > > Jeroen > > _______________________________________________ Libpqxx-general mailing list Libpqxx-general@gborg.postgresql.org http://gborg.postgresql.org/mailman/listinfo/libpqxx-general