mirror of
https://github.com/minio/minio.git
synced 2025-01-12 07:23:23 -05:00
Merge pull request #38 from fkautz/pr_out_migrating_from_unix_ts_to_time_time
This commit is contained in:
commit
3f6ddada56
@ -52,10 +52,10 @@ func (storage *Storage) StoreObject(bucket string, key string, data io.Reader) e
|
|||||||
size := bytesBuffer.Len()
|
size := bytesBuffer.Len()
|
||||||
etag := fmt.Sprintf("%x", sha256.Sum256(bytesBuffer.Bytes()))
|
etag := fmt.Sprintf("%x", sha256.Sum256(bytesBuffer.Bytes()))
|
||||||
newObject.metadata = mstorage.ObjectMetadata{
|
newObject.metadata = mstorage.ObjectMetadata{
|
||||||
Key: key,
|
Key: key,
|
||||||
SecCreated: time.Now().Unix(),
|
Created: time.Now(),
|
||||||
Size: size,
|
Size: size,
|
||||||
ETag: etag,
|
ETag: etag,
|
||||||
}
|
}
|
||||||
newObject.data = bytesBuffer.Bytes()
|
newObject.data = bytesBuffer.Bytes()
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ func (storage *Storage) StoreBucket(bucketName string) error {
|
|||||||
newBucket := storedBucket{}
|
newBucket := storedBucket{}
|
||||||
newBucket.metadata = mstorage.BucketMetadata{
|
newBucket.metadata = mstorage.BucketMetadata{
|
||||||
Name: bucketName,
|
Name: bucketName,
|
||||||
Created: time.Now().Unix(),
|
Created: time.Now(),
|
||||||
}
|
}
|
||||||
log.Println(bucketName)
|
log.Println(bucketName)
|
||||||
storage.bucketdata[bucketName] = newBucket
|
storage.bucketdata[bucketName] = newBucket
|
||||||
|
@ -19,6 +19,7 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Storage interface {
|
type Storage interface {
|
||||||
@ -35,14 +36,14 @@ type Storage interface {
|
|||||||
|
|
||||||
type BucketMetadata struct {
|
type BucketMetadata struct {
|
||||||
Name string
|
Name string
|
||||||
Created int64
|
Created time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type ObjectMetadata struct {
|
type ObjectMetadata struct {
|
||||||
Key string
|
Key string
|
||||||
SecCreated int64
|
Created time.Time
|
||||||
Size int
|
Size int
|
||||||
ETag string
|
ETag string
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsValidBucket(bucket string) bool {
|
func IsValidBucket(bucket string) bool {
|
||||||
|
@ -56,8 +56,7 @@ func (server *minioApi) getObjectHandler(w http.ResponseWriter, req *http.Reques
|
|||||||
object := vars["object"]
|
object := vars["object"]
|
||||||
|
|
||||||
metadata := server.storage.GetObjectMetadata(bucket, object)
|
metadata := server.storage.GetObjectMetadata(bucket, object)
|
||||||
lastModifiedTime := time.Unix(metadata.SecCreated, 0)
|
lastModified := metadata.Created.Format(time.RFC1123)
|
||||||
lastModified := lastModifiedTime.Format(time.RFC1123)
|
|
||||||
w.Header().Set("ETag", metadata.ETag)
|
w.Header().Set("ETag", metadata.ETag)
|
||||||
w.Header().Set("Last-Modified", lastModified)
|
w.Header().Set("Last-Modified", lastModified)
|
||||||
_, err := server.storage.CopyObjectToWriter(w, bucket, object)
|
_, err := server.storage.CopyObjectToWriter(w, bucket, object)
|
||||||
@ -205,7 +204,7 @@ func generateObjectsListResult(bucket string, objects []mstorage.ObjectMetadata)
|
|||||||
for _, object := range objects {
|
for _, object := range objects {
|
||||||
content := Content{
|
content := Content{
|
||||||
Key: object.Key,
|
Key: object.Key,
|
||||||
LastModified: formatDate(object.SecCreated),
|
LastModified: formatDate(object.Created),
|
||||||
ETag: object.ETag,
|
ETag: object.ETag,
|
||||||
Size: object.Size,
|
Size: object.Size,
|
||||||
StorageClass: "STANDARD",
|
StorageClass: "STANDARD",
|
||||||
@ -222,7 +221,6 @@ func generateObjectsListResult(bucket string, objects []mstorage.ObjectMetadata)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatDate(sec int64) string {
|
func formatDate(t time.Time) string {
|
||||||
timeStamp := time.Unix(sec, 0)
|
return t.Format("2006-01-02T15:04:05.000Z")
|
||||||
return timeStamp.Format("2006-01-02T15:04:05.000Z")
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user