Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Loading data (file) into blob-field
Mon, Mar 6 2017 11:17 AMPermanent Link

scwa

hi there,
i want to save a file into a blob-field. In delphi i can do that with field.LoadFromFile. Is there something equal in Web Builder or do someone have a workaround?
Thx and regards
Walid
Mon, Mar 6 2017 11:34 AMPermanent Link

Walter Matte

Tactical Business Corporation

I do this in the back end server.

The user uploads a file to the server and in my delphi server I do a filed.loadfromstream into a blob.

Walter


scwa wrote:

hi there,
i want to save a file into a blob-field. In delphi i can do that with field.LoadFromFile. Is there something equal in Web Builder or do someone have a workaround?
Thx and regards
Walid
Mon, Mar 6 2017 11:47 AMPermanent Link

scwa

Thats what i am searching for. But the TDataColumn does not have a method to load from a stream. Do you have some piece of code for choosing/saving the file on the server and then saving it into the field?


Walter Matte wrote:

I do this in the back end server.

The user uploads a file to the server and in my delphi server I do a filed.loadfromstream into a blob.

Walter


scwa wrote:

hi there,
i want to save a file into a blob-field. In delphi i can do that with field.LoadFromFile. Is there something equal in Web Builder or do someone have a workaround?
Thx and regards
Walid
Mon, Mar 6 2017 1:13 PMPermanent Link

Uli Becker

Walter was talking about his backend server. He uses his own server written with Delphi.

Uli
Tue, Mar 7 2017 2:24 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Walid,

<< i want to save a file into a blob-field. In delphi i can do that with field.LoadFromFile. Is there something equal in Web Builder or do someone have a workaround? >>

You'll need to do this on the back-end web server.  If you're using the EWB Web Server, then you will need to use an EWB Web Server module to accept the file information and then post it to the BLOB field.

I've got a new example application that I'm working on that will show how this is accomplished, but for now you can view the Form Submittal Example project to see how this is handled on the client side.  On the EWB Web Server/module side of things, you will need to create an EWB Web Server module to do what you want:

http://www.elevatesoft.com/manual?action=topics&id=ewb2mod&product=rsdelphiwin32&version=10B&section=getting_started

In the module, you can grab the incoming file data via this property:

http://www.elevatesoft.com/manual?action=viewprop&id=ewb2mod&product=rsdelphiwin32&version=10B&comp=TEWBServerRequest&prop=RequestMIMEParts

The MIME part will contain the file contents that were uploaded in this property:

http://www.elevatesoft.com/manual?action=viewprop&id=ewb2mod&product=rsdelphiwin32&version=10B&comp=TEWBMIMEPart&prop=Content

And you can save it to a stream using this method:

http://www.elevatesoft.com/manual?action=viewmethod&id=ewb2mod&product=rsdelphiwin32&version=10B&comp=TEWBMIMEPart&method=Save

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Mar 15 2017 2:08 PMPermanent Link

scwa

Tim,
<<I've got a new example application that I'm working on that will show how this is accomplished.

Looking forward to this.  I would like to understand it better.

Walid
Wed, Mar 20 2019 8:31 AMPermanent Link

DFL

Checking to see if this example was ever published as I am trying to accomplish the same thing.  Below is the Delphi code I use to read and write my data array into a blob field in a database - can I do this in EWB?


In Delphi, I retrieve an array from the blob field in my database as follows:

var
 blobF: TBlobField;
 bs: TStream;
begin
   if CDSschedtble.FieldByName('schdblob').IsBlob then
   begin
     blobF := CDSschedtble.FieldByName('schdblob') as TBlobField;
     bs := CDSschedtble.CreateBlobStream(blobF, bmRead);

     try
       bs.Read(schdvwinfo, sizeof(schdvwinfo));
     finally
       bs.Free;
     end;


To save the array as a blob, I store it as follows:

var
 blobF: TBlobField;
 bs: TStream;

begin
blobF := CDSschedtble.FieldByName('schdblob') as TBlobField;
   bs := CDSschedtble.CreateBlobStream(blobF, bmWrite);
   try
     bs.Write(schdvwinfo, sizeof(schdvwinfo));
   finally
     bs.Free;
   end; { try }



Are there similar commands in EWB I can use for this?



Tim Young [Elevate Software] wrote:

Walid,

<< i want to save a file into a blob-field. In delphi i can do that with field.LoadFromFile. Is there something equal in Web Builder or do someone have a workaround? >>

You'll need to do this on the back-end web server.  If you're using the EWB Web Server, then you will need to use an EWB Web Server module to accept the file information and then post it to the BLOB field.

I've got a new example application that I'm working on that will show how this is accomplished, but for now you can view the Form Submittal Example project to see how this is handled on the client side.  On the EWB Web Server/module side of things, you will need to create an EWB Web Server module to do what you want:

http://www.elevatesoft.com/manual?action=topics&id=ewb2mod&product=rsdelphiwin32&version=10B§ion=getting_started

In the module, you can grab the incoming file data via this property:

http://www.elevatesoft.com/manual?action=viewprop&id=ewb2mod&product=rsdelphiwin32&version=10B&comp=TEWBServerRequest&prop=RequestMIMEParts

The MIME part will contain the file contents that were uploaded in this property:

http://www.elevatesoft.com/manual?action=viewprop&id=ewb2mod&product=rsdelphiwin32&version=10B&comp=TEWBMIMEPart&prop=Content

And you can save it to a stream using this method:

http://www.elevatesoft.com/manual?action=viewmethod&id=ewb2mod&product=rsdelphiwin32&version=10B&comp=TEWBMIMEPart&method=Save

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Mar 21 2019 11:11 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Checking to see if this example was ever published as I am trying to accomplish the same thing. >>

I didn't do one for writing to a BLOB, but the PDF web server module example project shows how to load a file stream as a response to a request, and you can use the same techniques for loading/storing BLOBs into the database:

https://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Example_Applications

under "PDF Module Example".

<< Below is the Delphi code I use to read and write my data array into a blob field in a database - can I do this in EWB? >>

You can, but you have to use it in an EWB Web Server module (or equivalent) on the server side.  You'll also need to figure out how you want to represent the array when sending it to/from the web server module.  The typical choice is JSON, and you can use these components to do so:

https://www.elevatesoft.com/manual?action=viewcomp&id=ewb2mod&product=rsdelphiwin32&version=10R&comp=TEWBJSONReader

https://www.elevatesoft.com/manual?action=viewcomp&id=ewb2mod&product=rsdelphiwin32&version=10R&comp=TEWBJSONWriter

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Mar 22 2019 8:36 PMPermanent Link

DFL

Thank you.  Does any of this get easier with EWB 3.0?



Tim Young [Elevate Software] wrote:

<< Checking to see if this example was ever published as I am trying to accomplish the same thing. >>

I didn't do one for writing to a BLOB, but the PDF web server module example project shows how to load a file stream as a response to a request, and you can use the same techniques for loading/storing BLOBs into the database:

https://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Example_Applications

under "PDF Module Example".

<< Below is the Delphi code I use to read and write my data array into a blob field in a database - can I do this in EWB? >>

You can, but you have to use it in an EWB Web Server module (or equivalent) on the server side.  You'll also need to figure out how you want to represent the array when sending it to/from the web server module.  The typical choice is JSON, and you can use these components to do so:

https://www.elevatesoft.com/manual?action=viewcomp&id=ewb2mod&product=rsdelphiwin32&version=10R&comp=TEWBJSONReader

https://www.elevatesoft.com/manual?action=viewcomp&id=ewb2mod&product=rsdelphiwin32&version=10R&comp=TEWBJSONWriter

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Mar 25 2019 11:53 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Thank you.  Does any of this get easier with EWB 3.0? >>

Yes, this *all* gets easier with EWB 3, which is why it's taking so long to complete.  The entire IDE, compiler, and interpreter (this last part was present, but not "visible" in the prior IDEs) have been re-written so that both the client and server applications can all be managed (compilation, debugging, and deployment) easily within the IDE.

Tim Young
Elevate Software
www.elevatesoft.com
Image