mirror of
https://github.com/rclone/rclone.git
synced 2025-11-29 05:47:23 +02:00
http: add basic metadata and provide it via serve
Co-authored-by: dougal <147946567+roucc@users.noreply.github.com>
This commit is contained in:
@@ -191,11 +191,12 @@ var _ fs.Fs = MemoryFs
|
||||
|
||||
// MemoryObject is an in memory object
|
||||
type MemoryObject struct {
|
||||
remote string
|
||||
modTime time.Time
|
||||
content []byte
|
||||
meta fs.Metadata
|
||||
fs fs.Fs
|
||||
remote string
|
||||
modTime time.Time
|
||||
content []byte
|
||||
meta fs.Metadata
|
||||
fs fs.Fs
|
||||
mimeType string
|
||||
}
|
||||
|
||||
// NewMemoryObject returns an in memory Object with the modTime and content passed in
|
||||
@@ -214,6 +215,12 @@ func (o *MemoryObject) WithMetadata(meta fs.Metadata) *MemoryObject {
|
||||
return o
|
||||
}
|
||||
|
||||
// WithMimeType adds mimeType to the MemoryObject
|
||||
func (o *MemoryObject) WithMimeType(mimeType string) *MemoryObject {
|
||||
o.mimeType = mimeType
|
||||
return o
|
||||
}
|
||||
|
||||
// Content returns the underlying buffer
|
||||
func (o *MemoryObject) Content() []byte {
|
||||
return o.content
|
||||
@@ -329,8 +336,14 @@ func (o *MemoryObject) Metadata(ctx context.Context) (fs.Metadata, error) {
|
||||
return o.meta, nil
|
||||
}
|
||||
|
||||
// MimeType on the object
|
||||
func (o *MemoryObject) MimeType(ctx context.Context) string {
|
||||
return o.mimeType
|
||||
}
|
||||
|
||||
// Check interfaces
|
||||
var (
|
||||
_ fs.Object = (*MemoryObject)(nil)
|
||||
_ fs.MimeTyper = (*MemoryObject)(nil)
|
||||
_ fs.Metadataer = (*MemoryObject)(nil)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user