From 07f29ef10e19eb0bfd19c1b506a073caf49b28e2 Mon Sep 17 00:00:00 2001 From: Olivier FAURAX Date: Thu, 16 Nov 2023 11:24:30 +0100 Subject: [PATCH] asrockrack: Rewind file read from beginning in uploadFirmware --- providers/asrockrack/helpers.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/providers/asrockrack/helpers.go b/providers/asrockrack/helpers.go index 6496cf49..c7f06532 100644 --- a/providers/asrockrack/helpers.go +++ b/providers/asrockrack/helpers.go @@ -226,6 +226,11 @@ func (a *ASRockRack) uploadFirmware(ctx context.Context, endpoint string, fwRead fieldName, fileName := "fwimage", "image" contentLength := multipartSize(fieldName, fileName) + fileSize + // Before reading the file, rewind to the beginning + if file, ok := fwReader.(*os.File); ok { + _, _ = file.Seek(0, 0) + } + // setup pipe pipeReader, pipeWriter := io.Pipe() defer pipeReader.Close()