我想使用 Delphi 2007 将我的应用程序从 Indy 9 升级到 10。现在由于找不到 DecodeToStream,因此不再编译。该代码使用 Bold 框架,因为有对 BoldElement 的引用。
有什么替代方法可以调用吗?
更新(我认为我过于简化前面的例子)
原始代码:
BlobStreamStr : String;
MIMEDecoder : TidDecoderMIME;
if (BoldElement is TBATypedBlob) then
begin
BlobStreamStr := copy(ChangeValue,pos(']',ChangeValue)+1,maxint);
(BoldElement as TBATypedBlob).ContentType := copy(ChangeValue,2,pos(']',ChangeValue)-2);
MIMEDecoder := TidDecoderMIME.Create(nil);
try
MIMEDecoder.DecodeToStream(BlobStreamStr,(BoldElement as TBATypedBlob).CreateBlobStream(bmWrite));
finally
FreeAndNil(MIMEDecoder);
end;
end
在我改变之后:
BlobStreamStr : String;
MIMEDecoder : TidDecoderMIME;
LStream : TIdMemoryStream;
if (BoldElement is TBATypedBlob) then
begin
BlobStreamStr := copy(ChangeValue, pos(']', ChangeValue) + 1, maxint);
(BoldElement as TBATypedBlob).ContentType := copy(ChangeValue, 2, pos(']',ChangeValue)-2);
MIMEDecoder := TidDecoderMIME.Create(nil);
LStream := TIdMemoryStream.Create;
try
MIMEDecoder.DecodeBegin(LStream);
MIMEDecoder.Decode(BlobStreamStr, 0, Length(BlobStreamStr));
LStream.Position := 0;
ReadTIdBytesFromStream(LStream, DecodedBytes, Length(BlobStreamStr));
// Should memory for this stream be released ??
(BoldElement as TBATypedBlob).CreateBlobStream(bmWrite).Write(DecodedBytes[0], Length(DecodedBytes));
finally
MIMEDecoder.DecodeEnd;
FreeAndNil(LStream);
FreeAndNil(MIMEDecoder);
end;
end
但我对自己的所有变化都没有信心,因为我对 Indy 不太了解。所以欢迎大家发表意见。我不明白的一件事是对 CreateBlobStream 的调用。我应该与 FastMM 核对,所以它不是 memleak。