[MM-45862] Set size and extension to fileinfo (#20681)

* Set size and extension to fileinfo

* Remove unnecessary check
Этот коммит содержится в:
Claudio Costa
2022-07-22 09:14:01 +02:00
коммит произвёл GitHub
родитель 3d7859396d
Коммит 9255671222
3 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@@ -24,10 +24,19 @@ const minFirstPartSize = 5 * 1024 * 1024 // 5MB
func (a *App) genFileInfoFromReader(name string, file io.ReadSeeker, size int64) (*model.FileInfo, error) {
ext := strings.ToLower(filepath.Ext(name))
info := &model.FileInfo{
Name: name,
MimeType: mime.TypeByExtension(ext),
Name: name,
MimeType: mime.TypeByExtension(ext),
Size: size,
Extension: ext,
}
if ext != "" {
// The client expects a file extension without the leading period
info.Extension = ext[1:]
}
if info.IsImage() {
config, _, err := a.ch.imgDecoder.DecodeConfig(file)
if err != nil {