|Subject:||Re: id ftp server stream directly to database|
|Posted by:||Remy Lebeau (TeamB) (email@example.com)|
|Date:||Thu, 17 Mar 2005|
"Maarten Bakker" <m.j.bakk…@planet.nl> wrote in message
> I have a webcam that can send images to a ftpserver. I want
> to use the indy component for this. I want to store the images
> directly to the database without storing them to the harddrive first.
Ok so far.
> I have tried to capture the "VStream" in the IdFTPServer1RetrieveFile
> event but that only works when I save it to a file.
OnRetreiveFile is for downloading data from the server to the client. Not
for uploading data from the client to the server. Use the OnStoreFile event
instead for uploading.
> In other words, I can't copy that stream to my blob field
Yes, you can. Assign VStream to be the blob stream itself. Then the data
will go directly to the database.
> LoadFromStream simply does not work
There is no LoadFromStream() method in blob streams, or any other stream for
that matter. Or are you trying to call LoadFromStream() on a blob field
> The stream remains empthy.
Then you are not using it correctly to begin with. Your code should be
doing something like the following:
procedure TForm1.IdFTPServerStoreFile(ASender: TIdFTPServerThread; const
AFileName: string; AAppend: Boolean; var VStream: TStream);
BlobField := ...;
if AAppend then begin
VStream := MyDataSet.CreateBlobStream(BlobField, bmReadWrite);
end else begin
VStream := MyDataSet.CreateBlobStream(BlobField, bmWrite);
To download a file from a database field to the client:
procedure TForm1.IdFTPServer1RetreiveFile(ASender: TIdFTPServerThread;
const AFileName: string; var VStream: TStream);
BlobField := ...;
VStream := MyDataSet.CreateBlobStream(BlobField, bmRead);
In both cases, make sure your database code is thread-safe, since
TIdFTPServer is multi-threaded.
id ftp server stream directly to database posted by Maarten Bakker on Thu, 17 Mar 2005