mirror of
https://github.com/rclone/rclone.git
synced 2025-12-12 06:24:14 +01:00
http: add basic metadata and provide it via serve
Some checks failed
build / windows (push) Has been cancelled
build / other_os (push) Has been cancelled
build / mac_amd64 (push) Has been cancelled
build / mac_arm64 (push) Has been cancelled
build / linux (push) Has been cancelled
build / go1.24 (push) Has been cancelled
build / linux_386 (push) Has been cancelled
build / lint (push) Has been cancelled
build / android-all (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/386 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/amd64 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v6 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v7 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm64 (push) Has been cancelled
Build & Push Docker Images / Merge & Push Final Docker Image (push) Has been cancelled
Some checks failed
build / windows (push) Has been cancelled
build / other_os (push) Has been cancelled
build / mac_amd64 (push) Has been cancelled
build / mac_arm64 (push) Has been cancelled
build / linux (push) Has been cancelled
build / go1.24 (push) Has been cancelled
build / linux_386 (push) Has been cancelled
build / lint (push) Has been cancelled
build / android-all (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/386 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/amd64 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v6 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v7 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm64 (push) Has been cancelled
Build & Push Docker Images / Merge & Push Final Docker Image (push) Has been cancelled
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)
|
||||
)
|
||||
|
||||
@@ -87,6 +87,7 @@ func TestMemoryObject(t *testing.T) {
|
||||
content = content[:6] // make some extra cap
|
||||
|
||||
o := object.NewMemoryObject(remote, now, content)
|
||||
o.WithMimeType("text/plain; charset=utf-8")
|
||||
|
||||
assert.Equal(t, content, o.Content())
|
||||
assert.Equal(t, object.MemoryFs, o.Fs())
|
||||
@@ -95,6 +96,7 @@ func TestMemoryObject(t *testing.T) {
|
||||
assert.Equal(t, now, o.ModTime(context.Background()))
|
||||
assert.Equal(t, int64(len(content)), o.Size())
|
||||
assert.Equal(t, true, o.Storable())
|
||||
assert.Equal(t, "text/plain; charset=utf-8", o.MimeType(context.Background()))
|
||||
|
||||
Hash, err := o.Hash(context.Background(), hash.MD5)
|
||||
assert.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user