Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to get non-metadata headers (e.g. content-range) from StatObject #1993

Open
skirsten opened this issue Aug 16, 2024 · 4 comments
Open

Comments

@skirsten
Copy link
Contributor

The minio.Core GetObject returns the headers but the StatObject does not.

As far as I can tell there is no way to get the headers that are not parsed into stat.Metadata and stat.UserMetadata for the HEAD method.

@klauspost
Copy link
Contributor

@skirsten Which headers are you missing?

@harshavardhana
Copy link
Member

The minio.Core GetObject returns the headers but the StatObject does not.

As far as I can tell there is no way to get the headers that are not parsed into stat.Metadata and stat.UserMetadata for the HEAD method.

Please share code, and don't leave us speculating.

@skirsten
Copy link
Contributor Author

Sorry, here is a complete example:

mc, err := minio.NewCore("...", &minio.Options{
	Creds:  credentials.NewStaticV4("...", "...", ""),
	Secure: true,
})
if err != nil {
	return err
}

options := minio.GetObjectOptions{}

err = options.SetRange(0, 100)
if err != nil {
	return err
}

// For GET we get the headers returned

obj, stat, headers, err := mc.GetObject(ctx, "bucket", "object", options)
if err != nil {
	return err
}
defer obj.Close()

// Need to get the contentRange to get the total size and the actual range that was returned by S3
contentRange := headers.Get("content-range")

fmt.Printf("read size: %d\n", stat.Size)
fmt.Printf("content-range (start-end/total): %s\n", contentRange)

// For the HEAD the headers do not get returned

stat, err = mc.StatObject(ctx, "bucket", "path", options)
if err != nil {
	return err
}

fmt.Printf("read size: %d\n", stat.Size)

return fmt.Errorf("no way to get the headers of the StatObject response")

@klauspost
Copy link
Contributor

It would need to be included in the ObjectInfo.

Parsing Range headers is quite a nightmare, though that would probably be the path to take.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants