summaryrefslogtreecommitdiff
path: root/workhorse/internal/upload/destination/filestore/filestore.go
blob: 2d88874bf258cdf93f1a80130b60aa4f5efc84d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// The filestore package has a consumer specific to uploading to local disk storage.
package filestore

import (
	"context"
	"io"
	"time"
)

type LocalFile struct {
	File io.WriteCloser
}

func (lf *LocalFile) Consume(_ context.Context, r io.Reader, _ time.Time) (int64, error) {
	n, err := io.Copy(lf.File, r)
	errClose := lf.File.Close()
	if err == nil {
		err = errClose
	}
	return n, err
}