当我在pdf文件上测试时,返回base64字符串的datasnap服务器方法会给我一个错误。其他pdf文件正常工作,唯一的区别是这个pdf文件比其他文件大得多 - 78MB。
HTTP / 1.1 500内部服务器错误
服务器:
function TdmData.GetJobDocumentFile: string;
var fp : string;
begin
Result := Emptystr;
with fdQuery1 do
begin
Close;
SQL.Clear;
SQL.Text := ' select doc_filename from DBA.documents';
Open;
fp := fieldbyname('doc_filename').asString;
Close;
UnPrepare;
end;
if (fp <> Emptystr) and FileExists(fp) then
begin
Result := EncodeFile(fp);
end;
end;
function TdmData.EncodeFile(const FileName: string): AnsiString;
var Stream: TMemoryStream;
begin
Result := EmptyAnsiStr;
Stream := TMemoryStream.Create;
try
Stream.LoadFromFile(Filename);
Result := EncodeBase64(stream.Memory, stream.Size);
finally
Stream.Free;
end;
end;
function TServerMethods1.GetDocumentFile : string;
begin
try
Result := dmData.GetJobDocumentFiledata;
finally
GetInvocationMetadata.CloseSession := True;
end;
end;
客户端:
function TdmData.GetJobDocumentFileData: string;
var ServerMethods1Client : TServerMethods1Client;
begin
ServerMethods1Client := nil;
ServerMethods1Client := TServerMethods1Client.Create(DSRestConnection1);
try
Result := ServerMethods1Client.GetJobDocumentFileData;
finally
ServerMethods1Client.Free;
ServerMethods1Client := nil;
end;
end;
我在这里遗漏了什么吗?通过datasnap发送/接收大字符串有限制吗?
任何其他信息都会很棒,谢谢。