From 86e3436d55382aecf4d816b638fd8249e7d14dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=BCnger?= Date: Wed, 15 Aug 2018 00:33:58 +0200 Subject: [PATCH] jottacloud: Add optional MimeTyper interface. --- backend/jottacloud/api/types.go | 1 + backend/jottacloud/jottacloud.go | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/backend/jottacloud/api/types.go b/backend/jottacloud/api/types.go index 2f2ae0dfb..22d7d711e 100644 --- a/backend/jottacloud/api/types.go +++ b/backend/jottacloud/api/types.go @@ -241,6 +241,7 @@ type JottaFile struct { ModifiedAt Time `xml:"currentRevision>modified"` Updated Time `xml:"currentRevision>updated"` Size int64 `xml:"currentRevision>size"` + MimeType string `xml:"currentRevision>mime"` MD5 string `xml:"currentRevision>md5"` } diff --git a/backend/jottacloud/jottacloud.go b/backend/jottacloud/jottacloud.go index 59a8ba697..8fd62d41e 100644 --- a/backend/jottacloud/jottacloud.go +++ b/backend/jottacloud/jottacloud.go @@ -104,6 +104,7 @@ type Object struct { size int64 modTime time.Time md5 string + mimeType string } // ------------------------------------------------------------ @@ -688,11 +689,17 @@ func (o *Object) Size() int64 { return o.size } +// MimeType of an Object if known, "" otherwise +func (o *Object) MimeType() string { + return o.mimeType +} + // setMetaData sets the metadata from info func (o *Object) setMetaData(info *api.JottaFile) (err error) { o.hasMetaData = true o.size = int64(info.Size) o.md5 = info.MD5 + o.mimeType = info.MimeType o.modTime = time.Time(info.ModifiedAt) return nil } @@ -891,10 +898,11 @@ func (o *Object) Remove() error { // Check the interfaces are satisfied var ( - _ fs.Fs = (*Fs)(nil) - _ fs.Purger = (*Fs)(nil) - _ fs.Copier = (*Fs)(nil) - _ fs.Mover = (*Fs)(nil) - _ fs.DirMover = (*Fs)(nil) - _ fs.Object = (*Object)(nil) + _ fs.Fs = (*Fs)(nil) + _ fs.Purger = (*Fs)(nil) + _ fs.Copier = (*Fs)(nil) + _ fs.Mover = (*Fs)(nil) + _ fs.DirMover = (*Fs)(nil) + _ fs.Object = (*Object)(nil) + _ fs.MimeTyper = (*Object)(nil) )