MM-15480: Add server support for Range on files (#10892)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
87ff64ea6d
Коммит
edd3cc890f
@@ -10,10 +10,15 @@ import (
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
|
||||
type ReadCloseSeeker interface {
|
||||
io.ReadCloser
|
||||
io.Seeker
|
||||
}
|
||||
|
||||
type FileBackend interface {
|
||||
TestConnection() *model.AppError
|
||||
|
||||
Reader(path string) (io.ReadCloser, *model.AppError)
|
||||
Reader(path string) (ReadCloseSeeker, *model.AppError)
|
||||
ReadFile(path string) ([]byte, *model.AppError)
|
||||
FileExists(path string) (bool, *model.AppError)
|
||||
CopyFile(oldPath, newPath string) *model.AppError
|
||||
|
||||
@@ -34,7 +34,7 @@ func (b *LocalFileBackend) TestConnection() *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *LocalFileBackend) Reader(path string) (io.ReadCloser, *model.AppError) {
|
||||
func (b *LocalFileBackend) Reader(path string) (ReadCloseSeeker, *model.AppError) {
|
||||
f, err := os.Open(filepath.Join(b.directory, path))
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("Reader", "api.file.reader.reading_local.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -84,7 +84,7 @@ func (b *S3FileBackend) TestConnection() *model.AppError {
|
||||
}
|
||||
|
||||
// Caller must close the first return value
|
||||
func (b *S3FileBackend) Reader(path string) (io.ReadCloser, *model.AppError) {
|
||||
func (b *S3FileBackend) Reader(path string) (ReadCloseSeeker, *model.AppError) {
|
||||
s3Clnt, err := b.s3New()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("Reader", "api.file.reader.s3.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
Ссылка в новой задаче
Block a user