Transcode File Uploading
This commit is contained in:
parent
f232e08945
commit
36fe3202e8
7 changed files with 248 additions and 4 deletions
21
task/hash.go
Normal file
21
task/hash.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue