[MM-26812] Add support for resumable file uploads (#15252)
* Implement AppendFile for FileBackend * Split test into subtests * [MM-26812] Add support for resumable file uploads (#15252) * Implement UploadSession * Implement UploadSessionStore * Add error strings * Implement resumable file uploads * Add UploadType * Fix retry layer tests * Regenerate store layers * Fix store error handling * Use base for filename * Prevent concurrent uploads on the same upload session * Fix erroneus error string * Improve error handling Co-authored-by: Mattermod <mattermod@users.noreply.github.com> * Fix translations Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6a58834f34
Коммит
9c272f0b20
13
app/file.go
13
app/file.go
@@ -118,6 +118,15 @@ func (a *App) WriteFile(fr io.Reader, path string) (int64, *model.AppError) {
|
||||
return backend.WriteFile(fr, path)
|
||||
}
|
||||
|
||||
func (a *App) AppendFile(fr io.Reader, path string) (int64, *model.AppError) {
|
||||
backend, err := a.FileBackend()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return backend.AppendFile(fr, path)
|
||||
}
|
||||
|
||||
func (a *App) RemoveFile(path string) *model.AppError {
|
||||
backend, err := a.FileBackend()
|
||||
if err != nil {
|
||||
@@ -157,7 +166,7 @@ func (a *App) getInfoForFilename(post *model.Post, teamId, channelId, userId, ol
|
||||
return nil
|
||||
}
|
||||
|
||||
info, err := model.GetInfoForBytes(name, data)
|
||||
info, err := model.GetInfoForBytes(name, bytes.NewReader(data), len(data))
|
||||
if err != nil {
|
||||
mlog.Warn(
|
||||
"Unable to fully decode file info when migrating post to use FileInfos",
|
||||
@@ -902,7 +911,7 @@ func (a *App) DoUploadFileExpectModification(now time.Time, rawTeamId string, ra
|
||||
channelId := filepath.Base(rawChannelId)
|
||||
userId := filepath.Base(rawUserId)
|
||||
|
||||
info, err := model.GetInfoForBytes(filename, data)
|
||||
info, err := model.GetInfoForBytes(filename, bytes.NewReader(data), len(data))
|
||||
if err != nil {
|
||||
err.StatusCode = http.StatusBadRequest
|
||||
return nil, data, err
|
||||
|
||||
Ссылка в новой задаче
Block a user