webdav: populate FileInfo.MIMEType in client

This commit is contained in:
Simon Ser 2020-01-21 22:46:56 +01:00
parent 23fa5c582c
commit 82bdd23de4
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -66,18 +66,25 @@ func fileInfoFromResponse(resp *internal.Response) (*FileInfo, error) {
return nil, err return nil, err
} }
var getType internal.GetContentType
if err := resp.DecodeProp(&getType); err != nil && !internal.IsNotFound(err) {
return nil, err
}
fi.Size = getLen.Length fi.Size = getLen.Length
fi.ModTime = time.Time(getMod.LastModified) fi.ModTime = time.Time(getMod.LastModified)
fi.MIMEType = getType.Type
} }
return fi, nil return fi, nil
} }
// TODO: getetag, getcontenttype // TODO: getetag
var fileInfoPropfind = internal.NewPropNamePropfind( var fileInfoPropfind = internal.NewPropNamePropfind(
internal.ResourceTypeName, internal.ResourceTypeName,
internal.GetContentLengthName, internal.GetContentLengthName,
internal.GetLastModifiedName, internal.GetLastModifiedName,
internal.GetContentTypeName,
) )
func (c *Client) Stat(name string) (*FileInfo, error) { func (c *Client) Stat(name string) (*FileInfo, error) {