diff options
Diffstat (limited to 'workhorse/internal/upload/destination/reader.go')
-rw-r--r-- | workhorse/internal/upload/destination/reader.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/workhorse/internal/upload/destination/reader.go b/workhorse/internal/upload/destination/reader.go new file mode 100644 index 00000000000..925a9468e14 --- /dev/null +++ b/workhorse/internal/upload/destination/reader.go @@ -0,0 +1,17 @@ +package destination + +import "io" + +type hardLimitReader struct { + r io.Reader + n int64 +} + +func (h *hardLimitReader) Read(p []byte) (int, error) { + nRead, err := h.r.Read(p) + h.n -= int64(nRead) + if h.n < 0 { + err = ErrEntityTooLarge + } + return nRead, err +} |