Marvin Blum
1 min readNov 30, 2018

--

Yes. I don’t know why it advances the reader, this is what I came up with:

reader := bufio.NewReader(file)

sniff, _ := reader.Peek(512)

mimeType := http.DetectContentType(sniff)

file.Seek(0, 0)

// use mimeType to check file type

I’m using io.Copy to write the file contents to a io.Pipe later.

--

--

Marvin Blum
Marvin Blum

Written by Marvin Blum

Software Engineer, Open Source Enthusiast, Co-Founder of Pirsch and Emvi.

Responses (1)