Can you tell what I am missing? s.tellg() returns a size of 0. I know
there is a largeobject there with that id, because I can do this right
before the below code and it works perfecltly:
pqxx::largeobjectaccess loGet(w,137396206,PGSTD::ios::in);
loGet.to_file("test.seqb");
...
pqxx::work w(*atr->getConn(),me);
pqxx::ilostream s(w, 137396206);
ofstream file("test.seqb", ios::out|ios::binary|ios::trunc);
pqxx::ilostream::pos_type size;
char * memblock(0);
cout << "Streaming blob into a file " << endl;
if(s.good())
{
size = s.tellg();
cout << "SIZE OF LOSTREAM " << size << endl; ==> prints out 0
memblock = new char [size];
s.seekg (0, ios::beg);
s.read (memblock, size);
file.write(memblock,size);
delete[] memblock;
file.close();
}
Thanks.
Hilton Perantunes wrote:
> Try a look on this:
> http://www.cplusplus.com/doc/tutorial/files.html
>
>
>
> On 9/4/07, *Shannon Allen * <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> I am trying to get comfortable using the lostream class for large
> objects. I have a large binary file that I am storing in a BLOB
> that I
> can get back out using largeobjectaccess and then use the
> to_file(file)
> method to write it back out and that works fine. However, I want to
> give users streaming functionality, but I need to know how to do it
> first :-) .
>
> What I would like to do first is stream this back out to a file,
> similar
> to what I've already done with largeobjectaccess::to_file(file), but
> instead I want to use lostream.
>
> Given this code, what do I need to do next?
>
> ...
> pqxx::work w(*atr->getConn(),me);
> pqxx::ilostream s(w, id5);
>
> ofstream file("test.seqb", ios::out | ios::binary | ios::trunc);
> cout << "Streaming blob into a file " << endl;
>
> //This isn't right
> if(s.good())
> {
> file << s;
> }
> cout << "Done Streaming blob into a file " << endl;
> file.close();
> ...
> _______________________________________________
> Libpqxx-general mailing list
> [email protected]
> <mailto:[email protected]>
> http://gborg.postgresql.org/mailman/listinfo/libpqxx-general
>
>
>
>
> --
> Hilton William Ganzo Perantunes
> Sistemas de Informação - Universidade Federal de Santa Catarina
> --
> Dinheiro não traz felicidade, mas dá uma sensação tão parecida... -_-
> ------------------------------------------------------------------------
>
> _______________________________________________
> Libpqxx-general mailing list
> [email protected]
> http://gborg.postgresql.org/mailman/listinfo/libpqxx-general
>
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general