getAttributes returns information about the specified blob using its name.
(ctx context.Context, name string)
| 128 | |
| 129 | // getAttributes returns information about the specified blob using its name. |
| 130 | func (rw *Azure) getAttributes(ctx context.Context, name string) (BlobAttributes, error) { |
| 131 | blobClient, err := getBlobClient(ctx, rw.cfg, name) |
| 132 | if err != nil { |
| 133 | return BlobAttributes{}, fmt.Errorf("cannot get Azure blob client, name: %s: %w", name, err) |
| 134 | } |
| 135 | |
| 136 | props, err := blobClient.GetProperties(ctx, &blob.GetPropertiesOptions{}) |
| 137 | if err != nil { |
| 138 | return BlobAttributes{}, err |
| 139 | } |
| 140 | |
| 141 | if props.ContentLength == nil { |
| 142 | return BlobAttributes{}, fmt.Errorf("expected content length but got none for blob %s: %w", name, err) |
| 143 | } |
| 144 | |
| 145 | if props.LastModified == nil { |
| 146 | return BlobAttributes{}, fmt.Errorf("expected last modified but got none for blob %s: %w", name, err) |
| 147 | } |
| 148 | |
| 149 | return BlobAttributes{ |
| 150 | Size: *props.ContentLength, |
| 151 | LastModified: *props.LastModified, |
| 152 | }, nil |
| 153 | } |
no test coverage detected