HeadObject returns the fileinfo for the given object name. Note that the metadata is not supported yet.
(ctx context.Context, bucketName, objectName string)
| 102 | // |
| 103 | // Note that the metadata is not supported yet. |
| 104 | func (b *s3Backend) HeadObject(ctx context.Context, bucketName, objectName string) (*gofakes3.Object, error) { |
| 105 | bucket, err := getBucketByName(bucketName) |
| 106 | if err != nil { |
| 107 | return nil, err |
| 108 | } |
| 109 | bucketPath := bucket.Path |
| 110 | |
| 111 | fp := path.Join(bucketPath, objectName) |
| 112 | fmeta, _ := op.GetNearestMeta(fp) |
| 113 | node, err := fs.Get(context.WithValue(ctx, conf.MetaKey, fmeta), fp, &fs.GetArgs{}) |
| 114 | if err != nil { |
| 115 | return nil, gofakes3.KeyNotFound(objectName) |
| 116 | } |
| 117 | |
| 118 | if node.IsDir() { |
| 119 | return nil, gofakes3.KeyNotFound(objectName) |
| 120 | } |
| 121 | |
| 122 | size := node.GetSize() |
| 123 | // hash := getFileHashByte(fobj) |
| 124 | |
| 125 | meta := map[string]string{ |
| 126 | "Last-Modified": node.ModTime().Format(timeFormat), |
| 127 | "Content-Type": utils.GetMimeType(fp), |
| 128 | } |
| 129 | |
| 130 | if val, ok := b.meta.Load(fp); ok { |
| 131 | metaMap := val.(map[string]string) |
| 132 | for k, v := range metaMap { |
| 133 | meta[k] = v |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | return &gofakes3.Object{ |
| 138 | Name: objectName, |
| 139 | // Hash: hash, |
| 140 | Metadata: meta, |
| 141 | Size: size, |
| 142 | Contents: noOpReadCloser{}, |
| 143 | }, nil |
| 144 | } |
| 145 | |
| 146 | // GetObject fetchs the object from the filesystem. |
| 147 | func (b *s3Backend) GetObject(ctx context.Context, bucketName, objectName string, rangeRequest *gofakes3.ObjectRangeRequest) (s3Obj *gofakes3.Object, err error) { |
nothing calls this directly
no test coverage detected