id parse on object get and put
This commit is contained in:
parent
f2a8e0197d
commit
4344bf841c
@ -112,12 +112,21 @@ func httpGetFile(ctx context.Context, rw http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s3Client := ctx.Value("s3Client").(*minio.Client)
|
s3Client := ctx.Value("s3Client").(*minio.Client)
|
||||||
id := r.URL.Query().Get("id")
|
idString := r.URL.Query().Get("id")
|
||||||
|
|
||||||
|
id := types.ParseID(idString)
|
||||||
|
|
||||||
|
if id == nil {
|
||||||
|
// Failed to parse ID
|
||||||
|
rw.WriteHeader(http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
log.Debug("S3 call 'StatObject': ", id)
|
log.Debug("S3 call 'StatObject': ", id)
|
||||||
objInfo, err := s3Client.StatObject(context.Background(), "dev", id, minio.GetObjectOptions{})
|
objInfo, err := s3Client.StatObject(context.Background(), id.Bucket, id.Key, minio.GetObjectOptions{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error("Failed to get object info: ", err)
|
||||||
rw.WriteHeader(http.StatusInternalServerError)
|
rw.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -129,9 +138,10 @@ func httpGetFile(ctx context.Context, rw http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("S3 call 'GetObject': ", id)
|
log.Debug("S3 call 'GetObject': ", id)
|
||||||
obj, err := s3Client.GetObject(context.Background(), "dev", id, minio.GetObjectOptions{})
|
obj, err := s3Client.GetObject(context.Background(), id.Bucket, id.Key, minio.GetObjectOptions{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error("Failed to get object: ", err)
|
||||||
rw.WriteHeader(http.StatusInternalServerError)
|
rw.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user