title: DecodeToStream in Indy10
body: <p>I want to upgrade my application from Indy 9 to 10 with Delphi 2007.
  Now this don't compile anymore as DecodeToStream is not found. 
  The code use Bold framwork as there is reference to BoldElement.</p>
  
  <p>Any alternative methods to call ?</p>
  
  <p><strong>UPDATE</strong> (I think I simplify previous example too much)</p>
  
  <p>Original code:</p>
  
  <pre><code>    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
  </code></pre>
  
  <p>After my change:</p>
  
  <pre><code>    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
  </code></pre>
  
  <p>But I'm not confident at all of my changes as I don't know Indy so much. So all comments are welcome. One thing I don't understand is the call to CreateBlobStream. I should check with FastMM so it isn't a memleak.</p>