implemented file upload

This commit is contained in:
Djeeberjr 2021-08-06 13:49:00 +02:00
parent b42f45afe9
commit e095a6ceb0

View File

@ -75,13 +75,13 @@ func httpGetFile(rw http.ResponseWriter, r *http.Request, s3Client *minio.Client
func httpPostFile(rw http.ResponseWriter, r *http.Request, s3Client *minio.Client) { func httpPostFile(rw http.ResponseWriter, r *http.Request, s3Client *minio.Client) {
filename := r.URL.Query().Get("id")
contentType := r.Header.Get("Content-Type") contentType := r.Header.Get("Content-Type")
mimeType, err, _ := mime.ParseMediaType(contentType) mimeType, _, _ := mime.ParseMediaType(contentType)
if mimeType != "multipart/form-data" || err != nil {
rw.WriteHeader(400)
return
}
r.ParseMultipartForm(10 << 20) s3Client.PutObject(context.Background(), bucketName, filename, r.Body, r.ContentLength, minio.PutObjectOptions{
ContentType: mimeType,
})
} }