main

mattermost/focalboard

Last updated at: 29/12/2023 09:40

file.go

TLDR

This file defines a function NewFileInfo that creates a new mm_model.FileInfo object with the provided name.

Methods

None

Classes

None

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package model

import (
	"mime"
	"path/filepath"
	"strings"

	"github.com/mattermost/focalboard/server/utils"
	mm_model "github.com/mattermost/mattermost-server/v6/model"
)

func NewFileInfo(name string) *mm_model.FileInfo {
	extension := strings.ToLower(filepath.Ext(name))
	now := utils.GetMillis()
	return &mm_model.FileInfo{
		CreatorId: "boards",
		CreateAt:  now,
		UpdateAt:  now,
		Name:      name,
		Extension: extension,
		MimeType:  mime.TypeByExtension(extension),
	}
}