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) {
|
func httpPostFile(rw http.ResponseWriter, r *http.Request, s3Client *minio.Client) {
|
||||||
|
|
||||||
contentType := r.Header.Get("Content-Type")
|
filename := r.URL.Query().Get("id")
|
||||||
mimeType, err, _ := mime.ParseMediaType(contentType)
|
|
||||||
if mimeType != "multipart/form-data" || err != nil {
|
|
||||||
rw.WriteHeader(400)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
r.ParseMultipartForm(10 << 20)
|
contentType := r.Header.Get("Content-Type")
|
||||||
|
mimeType, _, _ := mime.ParseMediaType(contentType)
|
||||||
|
|
||||||
|
s3Client.PutObject(context.Background(), bucketName, filename, r.Body, r.ContentLength, minio.PutObjectOptions{
|
||||||
|
ContentType: mimeType,
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user