itnax.blogg.se

Format blob image delphi
Format blob image delphi







format blob image delphi
  1. Format blob image delphi how to#
  2. Format blob image delphi zip file#
  3. Format blob image delphi full#
  4. Format blob image delphi code#
format blob image delphi

Given the above explanation, the following procedure that restores the BLOB to the disk should be clear: Procedure TfrmMain.StoreBlob(FileName, FieldName: string) īlob.CopyFrom(myFileStream, myFileStream.Size)

Format blob image delphi full#

MyFileStream := TFileStream.Create(FileName, fmShareDenyWrite) įinally, you copy the data from the file stream into the BlobStream:īlob.CopyFrom(myFileStream, myFileStream.Size) įollowing is the full procedure that stores the BLOB in the data field:

Format blob image delphi code#

If you declare a variable "myFileStream" as a TStream type, the following code does the job: Next, the file stream has to be created to read from the source. The Seek function is called to move the position of the stream to the beginning of the resource on the disk and to return the value of the new position: If you declare a variable "blob" as a TStream type and name the ClientDataSet as "cds" the following code is used to create the BLOB stream for writing to it:īlob := cds.CreateBlobStream(cds.FieldByName(FieldName), bmWrite) The function CreateBlobStream expects two parameters: the BLOB field name and the mode which indicates whether the stream will be used for reading, writing, or updating the contents of the field. In the event that FetchOnDemand is set to False, you must call FetchBlobs before calling CreateBlobStream. By calling CreateBlobStream you ensure that the current record has fetched its BLOB data. By default, the FetchOnDemand property of the ClientDataSet is set to True. On the ClientDataSet side, I call the function CreateBlobStream to obtain a stream for writing data to the BLOB field. I use streams to read from a source file and write the result into a BLOB data field. Since I do not need any undo functionality or have to apply against a database server, I have turned off logging with the LogChanges property to conserve system resources. Two are of type ftBlob and will hold our BLOBs, and two others are of type ftString to hold the associated file names. I created five fields, using the Field Editor of the ClientDataSet. You will be able to store these BLOBs and to restore them to a specified location on your drive. The record will also store the associated file names. In addition, it will have the option to store another BLOB in the same record, such as an executable, or a MS Word document. The example will store a BMP image as a BLOB and display it in the application. Note that not all databases support BLOBs. You can use any database that supports BLOBs, such as SQL Server or Oracle. Image shown above is also stored as a BLOB in the same record.įor our purposes, I will use a TClientDataSet to create a custom local database to store our BLOBs. The zip fileĬontains the full source code, executable and database file that make up this project!

Format blob image delphi zip file#

Of a zip file that is stored as a BLOB in the same record.

Format blob image delphi how to#

This example shows you how to work with BLOBs using Delphi. This example will show you how you can use Delphi to store BLOBs in a database and restore them to disk on demand. However, they can also be used to hold other types of data, such as executables, zip files, code and documents. BLOBs are usually used to hold digitized multimedia content such as images, sound clips and videos. Working With BLOBs Using Delphi What is a BLOB?īLOB is an acronym that stands for Large Binary Object, which is a collection of binary data stored in a data field in a database that supports this functionality.









Format blob image delphi