#1 2017-10-24 13:24:40

jaclas
Member
Registered: 2014-09-12
Posts: 215

Upload file to method base service

I found examples on forum and I build service with upload file:

procedure TFileDownloadUploadRest.Upload(Ctxt: TSQLRestServerURIContext);
var
  aFileName: string;
  aFilePath: string;
begin
    case Ctxt.Method of
    mPOST,mPUT:
    begin
      aFileName := 'R:\test.bin';
      FileFromString(Ctxt.Call.InBody, aFileName);
      Ctxt.Success;
    end;
end;

but in saved file (at beginning file) I get unnecessary data:

-----------------------------7e12762010838
Content-Disposition: form-data; name="fileToUpload"; filename="C:\Users\Jacek\Downloads\file.bin"
Content-Type: application/octet-stream

MZP      ˙˙  ¸       @                                     ş ´	Í!¸LÍ!This program must be run under Win32
$7                                                                                                         

In fact, the beginning of the file is from the bytes MZP...


How get real data of file, without header data?

Offline

#2 2017-10-24 14:03:03

Chaa
Member
Registered: 2011-03-26
Posts: 249

Re: Upload file to method base service

Take a look at TSQLRestServerURIContext.InputAsMultiPart.

Offline

#3 2017-10-24 14:45:03

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Upload file to method base service

Thanks!

Offline

Board footer

Powered by FluxBB