I want to access my local volume to store files from user. I mapped volume using docker compose but i can't access it in golang.
webapi:
image: golang:1.12.0-alpine3.9
restart: always
container_name: webapi
ports:
- "8081:8081"
volumes:
- ./api/ :/go/src/
tempFile, err := ioutil.TempFile("./images/", "upload-*.png")
if err != nil {
fmt.Println(err)
}
filestate, err := tempFile.Stat()
filepath := filestate.Name()
defer tempFile.Close()
// read all of the contents of our uploaded file into a
// byte array
fileBytes, err := ioutil.ReadAll(file)
if err != nil {
fmt.Println(err)
}
// write this byte array to our temporary file
tempFile.Write(fileBytes)