2

What is the best method to send a large (<50MB) file from a PHP server (written in RADPHP) to a Delphi Datasnap server (Delphi XE). Because of the connectivity issues I would prefer to use HTTP(S) but this is new territory for me.

The PHP server accepts the file upload from the user's browser OK and can encode it (base_64). But a) that puts it into a string which can't be the best way to handle it b) the DataSnap server crashes with 'Max Line Length Exceeded' on receiving the string

The Datasnap server has 4 components - TDSServer, TDSServerClass, TDSHTTPService, and TDSAuthenticationManager. The RADPHP server uses a DSRestConnection component.

user1235807
  • 59
  • 1
  • 5
  • 1
    I suspect that you want to use DataSnap to handle URLs and write real files to disk, and then serve that giant file statically, not via a string in datasnap. – Warren P Feb 27 '12 at 19:43

1 Answers1

1

I'm not very familiar with Datasnap, but couldn't you do something like:

  • Client uploads file to RadPHP server
  • now you want to send that to a Datasnap server, what you can do, is send a command with a link to download it something like:

RadPHP: hey, new file for you, here's the link: "http://www.mydomain.com/files/filename.extension"

Datasnap: sends a response, i.e. "OK", and starts downloading, on the server side you can use TIdHTTP for example.

and the implementation could be something like:

procedure DatasnapServerClass.NewFile(const ALink: string);
var
  LIDHTTP: TIdHTTP;
begin
// create instance of TIdHTTP, and call the link to 
// download the file to your desired local folder
// using ALink as the URL
end;
  • Thanks that is a possibility but I was trying to achieve it in a single step, and without opening up directories for remote write access (the Datasnap server would want to delete after downloading). – user1235807 Mar 01 '12 at 15:47
  • personally, I don't think it's possible, but then again, I'm not using datasnap at all, so I'm not very familiar with what's possible and what's not possible, that being said, I'm certain that this works. –  Mar 01 '12 at 16:55
  • TDSHTTPService has been my focus so far to see if I can find where to set maximum string length as small files work fine. Help is a little sparse! Thanks for your quick response. – user1235807 Mar 01 '12 at 17:56
  • you're going to send base64 encoded data, this will increase bandwidth usage, I hope you'll reconsider using direct binary transfer on an event... –  Mar 01 '12 at 18:11
  • The serverfunctionexecutor unit had 'restrictions' for POSTing - submitted an initial fix to Embarcadero, hopefully they will update this unit to be fully functional. Filesize rethought too - as the users will be uploading from home/ small office set a 10MB limit anyway. – user1235807 Mar 15 '12 at 17:38