implemented file upload
This commit is contained in:
parent
b42f45afe9
commit
e095a6ceb0
@ -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) {
|
||||
|
||||
filename := r.URL.Query().Get("id")
|
||||
|
||||
contentType := r.Header.Get("Content-Type")
|
||||
mimeType, err, _ := mime.ParseMediaType(contentType)
|
||||
if mimeType != "multipart/form-data" || err != nil {
|
||||
rw.WriteHeader(400)
|
||||
return
|
||||
}
|
||||
mimeType, _, _ := mime.ParseMediaType(contentType)
|
||||
|
||||
r.ParseMultipartForm(10 << 20)
|
||||
s3Client.PutObject(context.Background(), bucketName, filename, r.Body, r.ContentLength, minio.PutObjectOptions{
|
||||
ContentType: mimeType,
|
||||
})
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user