Products

Price/Order

Support

Partners

Testimonials

Test Results

About us

Contact
 ISAPI File Upload
Bottom
 
Total posts: 7
 Author ISAPI File Upload
Gary Bell

13.09.2006 20:29:25
Registered user
Daniel,

I may not be far enough along knowledge wise to ask this yet so bear with me.  I've gone through the tutorials and everything is making sense so far.  With my new found knowledge I decided to try to create an ISAPI extension that accepted file uploads.   I essentially took the rtcUploadServer from the QuickStart folder and converted that to an ISAPI extension.   I then modified the rtcUploadClient to post to the modified URL.  It does get to the CheckRequest method and accepts it and it sends part of the file, but then appears to hang.

1)  Should I abandon this approach as it's ill founded?  If so can you nudge me in the right direction?
2)  From the client end of things can I build a request that simulates the mulipart/form like a browser would?

Thanks for any help you can provide.
Danijel Tkalcec [RTC]

13.09.2006 20:57:13
Registered user
1) It depends on what you want your Server to do. If it will have to accept files from a Browser, you should take the example under "QuickStart/Delphi_BrowserUpload", which handles file uploads in the "form/multipart" format. The example you have used is for sending files directly between a RTC Client to a RTC Server, since it sends raw data.

Also, it will depend on your WebServer (where you install the ISAPI) whether you will be able to upload large files or not (some Servers could have a problem with large requests).

If your ISAPI extension hangs during upload, try running it from Delphi by using the RTC WebServer as Host App, so you can debug it and see what is happening there.

2) You can send anything you want from the Client to the Server, since you write "raw data". But, there are no automatisms built into RTC Client components for sending data preformated in the "form/multipart" format. I could add that functionality later, but it would only work for files which already exist on your drive, since I would need to scan all files to define a delimiter for multipart content.

Best Regards,
Danijel Tkalcec
Danijel Tkalcec [RTC]

13.09.2006 21:20:55
Registered user
Btw ... if you have other components/classes which can prepare a file or stream formatted in multipart/form-data, you can send that file or stream out as "raw data".
Gary Bell

13.09.2006 22:28:39
Registered user
Daniel,

Thanks for you quick response.  I've got a lot to learn, but I'm really loving RTC.   I was using the personal IIS that comes with XP and it was not working, but as you suggested I used RTC Webserver and it worked fine.  I've got to figure out what my problem is as I have to use IIS in production for this particular project, but at least I know I'm heading in the right direction.

Thanks again,

Gary Bell
Gary Bell

14.09.2006 04:01:27
Registered user
Daniel,

As I said, the RTC web server worked fine with my ISAPI upload DLL.  I then set out to figure out why it doesn't work with IIS.  I have some more information on that.  It seems IIS will only pass 48K of the Request to the ISAPI.DLL (I think only on POST or PUT).  I'm having difficulty reading the rest of the data stream from the DataReceived event.  The S:=Read in that event will only read 48K and then the DataReceived is not called again.   In addition, in most cases, the server is sending a Response back right then with a Status code of 100 (Continue).  It seems to be confusing the client.  I realize this isn't a problem with RTC, but I think solving this may be beneficial to other users.   Any suggestions or have you run into this before?

procedure TDataModule1.rtcDP1DataReceived(Sender: TRtcConnection);
var
  s:string;
begin
  with TRtcDataServer(Sender) do
  begin
    if Request.Started then
    begin
//      if not DirectoryExists(eUploadFolder.Text) then
//        CreateDir(eUploadFolder.Text);
//      Delete_File(Request.Info['file']);
    end;
    s:=Read;  // This will return 48K every time if the ContentLength > 48K
//    Write_File(Request.Info.asString['file'], s, Request.ContentIn-length(s));
    if Request.Complete then
    begin
      Response.Status(200,'OK');
      Write;
    end;
  end;
end;
Danijel Tkalcec [RTC]

14.09.2006 22:09:51
Registered user
Thank you very much for sending me your test projects per E-Mail. After doing a few tests, I found where the problem is and (as much as I hate to addmit this) it was a "bug" in the RTC SDK. Namely ... I have expected the WebServer to fill the receiving buffer (which I set to 32K), but instead of that, IIS decided to fill only 17K. Since I have handled this as an internal Server error, I've been raising an exception and IIS was responding with "100 Continue" since it didn't have anything to send to the Client.

To make a long story short ... I fixed the thing and will be including this fix as part of the RTC SDK 2.0 next week. And in case someone wants to apply the fix before, I have uploaded the fixed unit "rtcISAPISrvProv.pas" to the download area. Simply replace the same file in the "Lib" folder.

Best Regards,
Danijel Tkalcec
Danijel Tkalcec [RTC]

15.09.2006 09:55:29
Registered user
And ... another related bug popped up, now at the client side. IIS server was sending a "100 Continue" with some data in the header, but RTC didn't expect any data with a "100 Continue" response, so it didn't handle the response propperly, so the client didn't receive the response sent from the Server. I've fixed that issue now and will be uploading the fixed client-side unit in the download area. This fix will also be included in the RTC SDK 2.0 package.

PS. Unless you are writing a RTC Client with "useProxy=False" which has to accept files from an ISAPI extension running under IIS, you probably won't need this fix.

Best Regards,
Danijel Tkalcec