"To process data of bytea type you need to retrieve the whole object
from the database into a memory. Next, you may use WMemoryResource or
save retrieved data to the file and use WFileResource."  "I think it is
reasonable to add WStreamResource into Wt -- the same as WFileResource
but for working with std::istream. I consider it useful."

"I believe it diserves a feature request and perhaps WFileResource could
be refactored to be a specializiatino of a WStreamResource."

I agree with these improvements. Today I did:

std::vector<unsigned char> vectorUChar;

std::ifstream file(uploadedFile.spoolFileName().c_str(), std::ios::in |
std::ios::binary | std::ios::ate);

if(file) {
  file.seekg(0, std::ios::end);
  std::ifstream::pos_type filesize = file.tellg();
  file.seekg(0, std::ios::beg);
  vectorUChar.resize(filesize);
  file.read((char*)(&vectorUChar[0]), filesize);
  file.close();
  std::remove(uploadedFile.spoolFileName().c_str());
}


I think UploadedFile could directly transform to std::vector<unsigned char>.

I still did not create the image reading from DB to the browser, but I
think using: WMemoryResource, then CREATE a File and then using
WFileResource + WImage is a slow process and it consumes more CPU and
disk space (why create a file that is in the db?).

By listing dozens of images of the database to the browser would be
better WImage (WResource) to read directly from the std::vector<unsigned
char> (DB field bytea).

Regards,
John


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to