Simplify saving segments to disk
This commit is contained in:
parent
00a740b6ca
commit
0d77856cb9
@ -1,7 +1,6 @@
|
|||||||
package transcoder
|
package transcoder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -35,7 +34,6 @@ func (s *FileWriterReceiverService) SetupFileWriterReceiverService(callbacks Fil
|
|||||||
|
|
||||||
localListenerAddress := "127.0.0.1:0"
|
localListenerAddress := "127.0.0.1:0"
|
||||||
|
|
||||||
// go func() {
|
|
||||||
listener, err := net.Listen("tcp", localListenerAddress)
|
listener, err := net.Listen("tcp", localListenerAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Unable to start internal video writing service", err)
|
log.Fatalln("Unable to start internal video writing service", err)
|
||||||
@ -59,13 +57,6 @@ func (s *FileWriterReceiverService) uploadHandler(w http.ResponseWriter, r *http
|
|||||||
|
|
||||||
path := r.URL.Path
|
path := r.URL.Path
|
||||||
writePath := filepath.Join(config.HLSStoragePath, path)
|
writePath := filepath.Join(config.HLSStoragePath, path)
|
||||||
|
|
||||||
var buf bytes.Buffer
|
|
||||||
defer r.Body.Close()
|
|
||||||
|
|
||||||
_, _ = io.Copy(&buf, r.Body)
|
|
||||||
data := buf.Bytes()
|
|
||||||
|
|
||||||
f, err := os.Create(writePath) //nolint: gosec
|
f, err := os.Create(writePath) //nolint: gosec
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnError(err, w)
|
returnError(err, w)
|
||||||
@ -73,7 +64,8 @@ func (s *FileWriterReceiverService) uploadHandler(w http.ResponseWriter, r *http
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if _, err := f.Write(data); err != nil {
|
|
||||||
|
if _, err := io.Copy(f, r.Body); err != nil {
|
||||||
returnError(err, w)
|
returnError(err, w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user