This is a library usage question,about ContentType.
xinjiajuan opened this issue · 1 comments
xinjiajuan commented
I saw that the Type File Struct has a field of ContentType that can be used, but this is just a struct and cannot get the ContentType of the file. Maybe I'm not very familiar with golang and would like to ask how to get it?
type File struct {
path string
name string
contentType string
size int64
modified time.Time
etag string
isdir bool
}
func (f File) ContentType() string {
return f.contentType
}
chripo commented
You need to cast the os.FileInfo
into our File
structure.
info, error := client.Stat('/file.txt')
...
if file, ok := info.(File); ok {
fmt.Println(file.ContentType())
}