1
0
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:
Oleg Kunitsyn
2025-11-17 17:52:30 +01:00
committed by GitHub
parent 80e6389a50
commit ecea0cd6f9
9 changed files with 232 additions and 12 deletions

View File

@@ -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)
)