[Lazarus] Brook-fpWeb POST without fields

Leonardo M. Ramé l.rame at griensu.com
Thu Mar 20 20:28:08 CET 2014


On 2014-03-20 16:23:36 -0300, silvioprog wrote:
> 2014-03-20 16:07 GMT-03:00 Leonardo M. Ramé <l.rame at griensu.com>:
> [...]
> 
> > Let me clarify this. My app is a CGI program running on an Apache
> > server, the client is a javascript file running on the same server.
> >
> > The relevant part of the client javascript is this:
> >
> >   blob = new Blob([data.buffer], {type: mimetype});
> >   var xhr = new XMLHttpRequest();
> >   xhr.open('POST', 'http://127.0.0.1:8080/cgi-bin/test', false);
> >   xhr.send(blob);
> >
> > As you can see, "blob" is an object containing a typed array that I'm
> > trying to send to the server using a POST command.
> 
> 
> So you need to send it via form-data. Using the form-data you will receive
> your buffer in Files property (it points to the "Request.Files" property of
> FCL-Web).
> 

Silvio, here's the solution. Just create a Post handler, then save
TheRequest.Content string as a TFileStream:

procedure TIndex.Post;
var
  lStream: TFileStream;
begin
  lStream := TFileStream.Create('output.odf', fmCreate);
  try
    lStream.Write(TheRequest.Content[1], TheRequest.ContentLength);
  finally
    lStream.Free;
  end;
end;

-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com




More information about the Lazarus mailing list