Transcode File Uploading

This commit is contained in:
Samuel Lorch 2024-06-23 03:30:08 +02:00
parent f232e08945
commit 36fe3202e8
7 changed files with 248 additions and 4 deletions

21
task/hash.go Normal file
View file

@ -0,0 +1,21 @@
package task
import (
"crypto/md5"
"fmt"
"io"
"os"
)
func hashFile(path string) ([]byte, error) {
file, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("Opening File: %w", err)
}
hash := md5.New()
if _, err := io.Copy(hash, file); err != nil {
return nil, fmt.Errorf("Reading File: %w", err)
}
return hash.Sum(nil), nil
}