jottacloud: Add optional MimeTyper interface.

This commit is contained in:
Sebastian Bünger 2018-08-15 00:33:58 +02:00 committed by Nick Craig-Wood
parent f243d2a309
commit 86e3436d55
2 changed files with 15 additions and 6 deletions

View file

@ -241,6 +241,7 @@ type JottaFile struct {
ModifiedAt Time `xml:"currentRevision>modified"` ModifiedAt Time `xml:"currentRevision>modified"`
Updated Time `xml:"currentRevision>updated"` Updated Time `xml:"currentRevision>updated"`
Size int64 `xml:"currentRevision>size"` Size int64 `xml:"currentRevision>size"`
MimeType string `xml:"currentRevision>mime"`
MD5 string `xml:"currentRevision>md5"` MD5 string `xml:"currentRevision>md5"`
} }

View file

@ -104,6 +104,7 @@ type Object struct {
size int64 size int64
modTime time.Time modTime time.Time
md5 string md5 string
mimeType string
} }
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -688,11 +689,17 @@ func (o *Object) Size() int64 {
return o.size return o.size
} }
// MimeType of an Object if known, "" otherwise
func (o *Object) MimeType() string {
return o.mimeType
}
// setMetaData sets the metadata from info // setMetaData sets the metadata from info
func (o *Object) setMetaData(info *api.JottaFile) (err error) { func (o *Object) setMetaData(info *api.JottaFile) (err error) {
o.hasMetaData = true o.hasMetaData = true
o.size = int64(info.Size) o.size = int64(info.Size)
o.md5 = info.MD5 o.md5 = info.MD5
o.mimeType = info.MimeType
o.modTime = time.Time(info.ModifiedAt) o.modTime = time.Time(info.ModifiedAt)
return nil return nil
} }
@ -891,10 +898,11 @@ func (o *Object) Remove() error {
// Check the interfaces are satisfied // Check the interfaces are satisfied
var ( var (
_ fs.Fs = (*Fs)(nil) _ fs.Fs = (*Fs)(nil)
_ fs.Purger = (*Fs)(nil) _ fs.Purger = (*Fs)(nil)
_ fs.Copier = (*Fs)(nil) _ fs.Copier = (*Fs)(nil)
_ fs.Mover = (*Fs)(nil) _ fs.Mover = (*Fs)(nil)
_ fs.DirMover = (*Fs)(nil) _ fs.DirMover = (*Fs)(nil)
_ fs.Object = (*Object)(nil) _ fs.Object = (*Object)(nil)
_ fs.MimeTyper = (*Object)(nil)
) )