fix: we need SeekEnd to spoof and just return the length of the file for http.ServeContent
This commit is contained in:
parent
bf15faf33f
commit
6d998eeff4
|
@ -53,8 +53,10 @@ func (f *File) Seek(offset int64, whence int) (int64, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
case io.SeekCurrent, io.SeekEnd:
|
case io.SeekCurrent:
|
||||||
return 0, errors.New("not supported")
|
return 0, errors.New("not supported")
|
||||||
|
case io.SeekEnd:
|
||||||
|
return int64(f.Size()), nil
|
||||||
default:
|
default:
|
||||||
return 0, errors.New("invalid whence")
|
return 0, errors.New("invalid whence")
|
||||||
}
|
}
|
||||||
|
@ -140,3 +142,11 @@ func (f *File) Modtime() time.Time {
|
||||||
|
|
||||||
return record.CreatedAt
|
return record.CreatedAt
|
||||||
}
|
}
|
||||||
|
func (f *File) Size() uint64 {
|
||||||
|
record, err := f.Record()
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return record.Size
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue