mirror of
https://github.com/minio/minio.git
synced 2025-11-10 14:09:48 -05:00
Implement bucket policy handler and with galore of cleanup
This commit is contained in:
59
pkg/api/minioapi/response.go
Normal file
59
pkg/api/minioapi/response.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package minioapi
|
||||
|
||||
import (
|
||||
mstorage "github.com/minio-io/minio/pkg/storage"
|
||||
)
|
||||
|
||||
func generateBucketsListResult(buckets []mstorage.BucketMetadata) BucketListResponse {
|
||||
var listbuckets []*Bucket
|
||||
var data = BucketListResponse{}
|
||||
var owner = Owner{}
|
||||
|
||||
owner.ID = "minio"
|
||||
owner.DisplayName = "minio"
|
||||
|
||||
for _, bucket := range buckets {
|
||||
var listbucket = &Bucket{}
|
||||
listbucket.Name = bucket.Name
|
||||
listbucket.CreationDate = bucket.Created.Format(dateFormat)
|
||||
listbuckets = append(listbuckets, listbucket)
|
||||
}
|
||||
|
||||
data.Owner = owner
|
||||
data.Buckets.Bucket = listbuckets
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// takes a set of objects and prepares the objects for serialization
|
||||
// input:
|
||||
// bucket name
|
||||
// array of object metadata
|
||||
// results truncated flag
|
||||
//
|
||||
// output:
|
||||
// populated struct that can be serialized to match xml and json api spec output
|
||||
func generateObjectsListResult(bucket string, objects []mstorage.ObjectMetadata, isTruncated bool) ObjectListResponse {
|
||||
var contents []*Item
|
||||
var owner = Owner{}
|
||||
var data = ObjectListResponse{}
|
||||
|
||||
owner.ID = "minio"
|
||||
owner.DisplayName = "minio"
|
||||
|
||||
for _, object := range objects {
|
||||
var content = &Item{}
|
||||
content.Key = object.Key
|
||||
content.LastModified = object.Created.Format(dateFormat)
|
||||
content.ETag = object.ETag
|
||||
content.Size = object.Size
|
||||
content.StorageClass = "STANDARD"
|
||||
content.Owner = owner
|
||||
contents = append(contents, content)
|
||||
}
|
||||
data.Name = bucket
|
||||
data.Contents = contents
|
||||
data.MaxKeys = MAX_OBJECT_LIST
|
||||
data.IsTruncated = isTruncated
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user