Skip to content

Commit

Permalink
fix: handle error when saving file
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielolivrp committed Nov 6, 2023
1 parent d403bfe commit 3902c68
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions utils/save_midia.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ func SaveMedia(instanceID string, fileName string, data []byte, mimetype string)
return "", err
}

exts, _ := mime.ExtensionsByType(mimetype)
exts, err := mime.ExtensionsByType(mimetype)
if err != nil {
return "", err
}
path := fmt.Sprintf("%s/%s%s", dirPath, fileName, exts[0])

err = os.WriteFile(path, data, 0600)
if err != nil {
// fmt.Println("failed to save file", err)
return "", err
}

// fmt.Println("file saved: ", path)
return path, nil
}

0 comments on commit 3902c68

Please sign in to comment.