File download

This commit is contained in:
2025-05-12 22:44:22 +08:00
parent bea9e24e98
commit 7be2d10472
5 changed files with 53 additions and 2 deletions

View File

@@ -85,7 +85,7 @@ func CreateFile(filename string, description string, resourceID uint, storageID
func GetFile(id uint) (*model.File, error) {
f := &model.File{}
if err := db.Where("id = ?", id).First(f).Error; err != nil {
if err := db.Preload("Storage").Where("id = ?", id).First(f).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, model.NewNotFoundError("file not found")
}