Re: .NET to Delphi 7



Bob_? wrote:
When I use the file stream in the HTTP request it doesn't work -- how do I get it to work with Indy HTTP?

"It doesn't work" doesn't tell me anything.

From the VB code you posted, it looks like the server is expecting the file to be included as the payload of a POST request. That's very easy to do with Indy. You have a TIdHTTP object. Call its Post method, passing it the destination address and a reference to the stream that contains what you want to post to that address.

Data := TFileStream.Create(LocalFile, ...);
try
  ResposeString := HTTP.Post(UploadURL, Data);
finally
  Data.Free;
end;

There are several other overloaded versions of TIdHTTP.Post. Look at the source (in IdHTTP.pas) to find the one that's most suited to your needs. If you want to receive the server's response in another stream, for instance, use the overload that takes a string and two streams as arguments, instead of the one I used above, which only takes one stream.

--
Rob
.



Relevant Pages

  • Re: indy example needed
    ... >>I need an example of how to post a file using Indy http client to an ... >>Indy http server and how to save it to the disk. ... > Tidhttp.post lets you send a stream, which could be a file stream. ...
    (comp.lang.pascal.delphi.misc)
  • Re: ostream, istream, and String^
    ... and understands compiler diagnostics *sigh*) ... > This takes the output stream given as a parameter, ... I fail to see how overload resolution could find a better match. ... BTW: .NET Strings are immutable. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: ostream, istream, and String^
    ... > Would you care to explain which error you see? ... both of which are something like 'no overload of '<<' ... This takes the output stream given as a parameter, ... So my problem is because String^ does not have a natural overload of '<<' ...
    (microsoft.public.dotnet.languages.vc)
  • RE: Read a dataset from a stream
    ... You need to use DataSet.ReadXmloverload. ... Should you get an exception for valid XML, ... > Does anyone have a method up their sleeve to read a DataSet from a Stream? ... > I know I could rewrite the decrypted XML to the file system, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Reading network socket stream, slow connection
    ... it only seems to grab a small chunk on the stream. ... If you step over it in the debugger, your program is paused long enough for the network driver to receive all of the data you're expecting. ... When your program runs without intervention, it reads data faster than it can be sent over the network, and so only reads a little bit at a time (whatever's been received by the network driver since the last time you read some data). ... The behavior you're seeing is by design, so as long as you properly accumulate the received data until you have enough to accomplish whatever processing you're going to do with the data, that's fine. ...
    (microsoft.public.dotnet.languages.csharp)