chore(app): migrate from ioutil to io
This commit is contained in:
parent
f6338abfd1
commit
ce6189685a
@ -2,7 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -36,12 +36,12 @@ func uploadFile(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
fileBytes, err := ioutil.ReadAll(file)
|
fileBytes, err := io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error reading file %v", err)
|
log.Fatalf("Error reading file %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ioutil.WriteFile(config.ImagePath, fileBytes, os.FileMode(0600))
|
os.WriteFile(config.ImagePath, fileBytes, os.FileMode(0600))
|
||||||
|
|
||||||
log.Println(aurora.Cyan("Successfully Uploaded File"))
|
log.Println(aurora.Cyan("Successfully Uploaded File"))
|
||||||
fmt.Fprintf(w, "Successfully Uploaded File\n")
|
fmt.Fprintf(w, "Successfully Uploaded File\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user