We're trying to load a CSV file into a stream and it's giving an error.
var
Arq2 : TMemoryStream;
PathArq : string;
begin
PathArq := 'C:\sincron\temp\produtos.txt' ;
Arq2 := TMemoryStream.Create; Arq2.LoadFromStream(spreadsheet); // the error is on this line
Arq2.SaveToFile(PathArq);
procedure TMemoryStream.LoadFromStream(Stream: TStream);
var
Count: Int64;
begin Stream.Position := 0; // Here that generates the excess
Count := Stream.Size;
SetSize(Count);
if Count <> 0 then Stream.ReadBuffer(FMemory^, Count);
end;
It still not clear where Planilha is coming from.
In any case, if it's a stream from Sparkle, it might be unidirecional only. You can't use LoadFromStream. You should copy one stream from another using buffers.
Something like this:
procedure CopyStream(Source, Dest: TStream);
const
TempBufferSize = 16384;
var
Buffer: TBytes;
BufLen: Int64;
BytesRead: Cardinal;
begin
BufLen := TempBufferSize;
SetLength(Buffer, BufLen);
repeat
BytesRead := Source.Read(Buffer[0], BufLen);
if BytesRead > 0 then
Dest.Write(Buffer[0], BytesRead);
until (BytesRead <> BufLen);
end;
Or you can simply get the content as bytes, not stream. But I can't say more as I don't know where Planilha is coming from.
It's always worked that way.
The data file.csv sent via POST on a request that will consume that importProductCSV endpoint
(Sempre usamos assim, e do nada começou esse problema. O arquivo criado dados.csv é enviado via POST numa requisição que consome nossa API, eu passei a imagem do nosso código ai) Acredito que nessa ultima versão de vocês, houve alguma mudança nesse sentido, so não sabemos como passar a usar esse recurso agora). Vou tentar usar esse copyStream que vc passou.