Last active
October 17, 2017 23:12
-
-
Save deekoder/4c6ef0e266a282c9e12df4eebdc8392a to your computer and use it in GitHub Desktop.
Uploading Images to Minio from Trichorder Ap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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