Project

General

Profile

Support #1444

how to save a binary file of the postgres database to a file on disk

Added by Marcio Sales over 9 years ago. Updated over 9 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
09/24/2012
Due date:
% Done:

0%

Estimated time:

Description

how to save a binary file of the postgres database to a file on disk

#1

Updated by Wim Dumon over 9 years ago

  • Status changed from New to Feedback

could you elaborate more in detail what you want to do?

BR,

Wim.

#2

Updated by Marcio Sales over 9 years ago

I need to save a binary field (record of table) of the postgres database to a file on disk

this field declared as std::vector

#3

Updated by Wim Dumon over 9 years ago

Marcio,

I propose something like:

std::ofstream outfile("filename.bin", std::ios::out | std::ios::binary);
outfile.write(&v[0], v.size());
outfile.close();

BR,

wim.

#4

Updated by Marcio Sales over 9 years ago

Wim,

thanks for the help but error occurred

erro: invalid conversion from 'const unsigned char*' to 'const char*' [-fpermissive]

Márcio

#5

Updated by Wim Dumon over 9 years ago

std::ofstream outfile("filename.bin", std::ios::out | std::ios::binary);
outfile.write((const char*)&v[0], v.size());
outfile.close();
#6

Updated by Marcio Sales over 9 years ago

thank you very much

#7

Updated by Marcio Sales over 9 years ago

Hi Wim,

I need more help.

this is a file zip and i need to get a one file of this zip, to show in component WMemoryResource

I got inflate the zip and get the file this is the code.

zip.OpenFromMemory((const char*)&attachment~~binarydata[0], attachment~~>binarydata.size());

after i got the file

CkZipEntry *entry = zip.FirstEntry();

and then i inflate

entry->Inflate(*outData);

and the problem is

wmr.setData(*outData->getData());

message: request for member 'setData' in 'wmr', which is of non-class type

#8

Updated by Marcio Sales over 9 years ago

solved

wmr->setData(outData.getData(),outData.getSize());

Also available in: Atom PDF