Rework writing to blob
This commit is contained in:
parent
c092e8fa8f
commit
ba94fe6d99
@ -202,15 +202,22 @@ FB_UDR_EXECUTE_FUNCTION
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is wrong - the calling application should pass in a blob handle
|
try {
|
||||||
AutoRelease<IBlob> Blob(att->createBlob(status, tra, &in->ablob, 0, nullptr));
|
|
||||||
if (Blob == nullptr) {
|
|
||||||
out->result = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<char> Buffer (MaxSegmentSize, 0);
|
att.reset(context->getAttachment(status));
|
||||||
streamsize DataSize;
|
tra.reset(context->getTransaction(status));
|
||||||
|
|
||||||
|
// This is wrong - the calling application should pass in a blob handle
|
||||||
|
//AutoRelease<IBlob> Blob(att->openBlob(status, tra, &in->ablob, 0, nullptr));
|
||||||
|
Blob.reset(att->openBlob(status, tra, &in->ablob, 0, nullptr));
|
||||||
|
|
||||||
|
if (Blob == nullptr) {
|
||||||
|
out->result = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<char> Buffer (MaxSegmentSize, 0);
|
||||||
|
std::streamsize DataSize;
|
||||||
|
|
||||||
while ( FileReader.good() ) {
|
while ( FileReader.good() ) {
|
||||||
FileReader.read( Buffer.data(), Buffer.size() );
|
FileReader.read( Buffer.data(), Buffer.size() );
|
||||||
@ -227,12 +234,17 @@ FB_UDR_EXECUTE_FUNCTION
|
|||||||
// Should we reset result to 0?
|
// Should we reset result to 0?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Blob->close( status );
|
||||||
|
Blob->release();
|
||||||
|
Buffer.clear();
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Error writing stream to BLOB.");
|
||||||
|
}
|
||||||
|
|
||||||
Blob->close( status );
|
FileReader.close();
|
||||||
Blob->release();
|
out->result = 1;
|
||||||
|
|
||||||
Buffer.clear();
|
|
||||||
File.close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user