Skip to content

Instantly share code, notes, and snippets.

@deekoder
Last active October 17, 2017 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deekoder/4c6ef0e266a282c9e12df4eebdc8392a to your computer and use it in GitHub Desktop.
Save deekoder/4c6ef0e266a282c9e12df4eebdc8392a to your computer and use it in GitHub Desktop.
Uploading Images to Minio from Trichorder Ap
func upload(w http.ResponseWriter, r *http.Request) {
file, header, err := r.FormFile("file")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer file.Close()
fname := header.Filename
minioClient, err := minio.New("192.168.1.15:9000", "minio", "minio123", false)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
n, err := minioClient.PutObject("barcodes", fname, file, header.Size, minio.PutObjectOptions{ContentType: "application/octet-stream"})
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Successfully put object %d\n", n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment