|
|
@ -261,7 +261,7 @@ func (storage *Storage) CopyObjectToWriter(w io.Writer, bucket string, object st |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetObjectMetadata - HEAD object
|
|
|
|
// GetObjectMetadata - HEAD object
|
|
|
|
func (storage *Storage) GetObjectMetadata(bucket, object string) (mstorage.ObjectMetadata, error) { |
|
|
|
func (storage *Storage) GetObjectMetadata(bucket, object, prefix string) (mstorage.ObjectMetadata, error) { |
|
|
|
if mstorage.IsValidBucket(bucket) == false { |
|
|
|
if mstorage.IsValidBucket(bucket) == false { |
|
|
|
return mstorage.ObjectMetadata{}, mstorage.BucketNameInvalid{Bucket: bucket} |
|
|
|
return mstorage.ObjectMetadata{}, mstorage.BucketNameInvalid{Bucket: bucket} |
|
|
|
} |
|
|
|
} |
|
|
@ -291,7 +291,6 @@ func (storage *Storage) GetObjectMetadata(bucket, object string) (mstorage.Objec |
|
|
|
var deserializedMetadata Metadata |
|
|
|
var deserializedMetadata Metadata |
|
|
|
decoder := gob.NewDecoder(file) |
|
|
|
decoder := gob.NewDecoder(file) |
|
|
|
err = decoder.Decode(&deserializedMetadata) |
|
|
|
err = decoder.Decode(&deserializedMetadata) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return mstorage.ObjectMetadata{}, mstorage.EmbedError(bucket, object, err) |
|
|
|
return mstorage.ObjectMetadata{}, mstorage.EmbedError(bucket, object, err) |
|
|
|
} |
|
|
|
} |
|
|
@ -306,9 +305,10 @@ func (storage *Storage) GetObjectMetadata(bucket, object string) (mstorage.Objec |
|
|
|
if len(deserializedMetadata.Md5sum) != 0 { |
|
|
|
if len(deserializedMetadata.Md5sum) != 0 { |
|
|
|
etag = hex.EncodeToString(deserializedMetadata.Md5sum) |
|
|
|
etag = hex.EncodeToString(deserializedMetadata.Md5sum) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
trimmedObject := strings.TrimPrefix(object, prefix) |
|
|
|
metadata := mstorage.ObjectMetadata{ |
|
|
|
metadata := mstorage.ObjectMetadata{ |
|
|
|
Bucket: bucket, |
|
|
|
Bucket: bucket, |
|
|
|
Key: path.Base(object), |
|
|
|
Key: trimmedObject, |
|
|
|
Created: stat.ModTime(), |
|
|
|
Created: stat.ModTime(), |
|
|
|
Size: stat.Size(), |
|
|
|
Size: stat.Size(), |
|
|
|
ETag: etag, |
|
|
|
ETag: etag, |
|
|
@ -395,13 +395,15 @@ func (storage *Storage) ListObjects(bucket string, resources mstorage.BucketReso |
|
|
|
delimitedName := delimiter(name, resources.Delimiter) |
|
|
|
delimitedName := delimiter(name, resources.Delimiter) |
|
|
|
switch true { |
|
|
|
switch true { |
|
|
|
case delimitedName == "": |
|
|
|
case delimitedName == "": |
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name) |
|
|
|
// Do not strip prefix object output
|
|
|
|
|
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name, "") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
} |
|
|
|
} |
|
|
|
metadataList = append(metadataList, metadata) |
|
|
|
metadataList = append(metadataList, metadata) |
|
|
|
case delimitedName == file.Name(): |
|
|
|
case delimitedName == file.Name(): |
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name) |
|
|
|
// Do not strip prefix object output
|
|
|
|
|
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name, "") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -414,13 +416,15 @@ func (storage *Storage) ListObjects(bucket string, resources mstorage.BucketReso |
|
|
|
delimitedName := delimiter(trimmedName, resources.Delimiter) |
|
|
|
delimitedName := delimiter(trimmedName, resources.Delimiter) |
|
|
|
switch true { |
|
|
|
switch true { |
|
|
|
case name == resources.Prefix: |
|
|
|
case name == resources.Prefix: |
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name) |
|
|
|
// Use resources.Prefix to filter out delimited files
|
|
|
|
|
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name, resources.Prefix) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
} |
|
|
|
} |
|
|
|
metadataList = append(metadataList, metadata) |
|
|
|
metadataList = append(metadataList, metadata) |
|
|
|
case delimitedName == file.Name(): |
|
|
|
case delimitedName == file.Name(): |
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name) |
|
|
|
// Use resources.Prefix to filter out delimited files
|
|
|
|
|
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name, resources.Prefix) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -433,7 +437,8 @@ func (storage *Storage) ListObjects(bucket string, resources mstorage.BucketReso |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
case strings.HasPrefix(name, resources.Prefix): |
|
|
|
case strings.HasPrefix(name, resources.Prefix): |
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name) |
|
|
|
// Do not strip prefix object output
|
|
|
|
|
|
|
|
metadata, err := storage.GetObjectMetadata(bucket, name, "") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
return []mstorage.ObjectMetadata{}, resources, mstorage.EmbedError(bucket, "", err) |
|
|
|
} |
|
|
|
} |
|
|
|