From d4ac444ce59f4535b7fd2619046273bbe1cd80f5 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Wed, 15 Dec 2021 18:35:47 +0800 Subject: [PATCH] fix: typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank 沉寂 for bringing this to our attention. --- leancloud/encoding.go | 2 +- leancloud/file.go | 16 ++++++++-------- leancloud/files.go | 20 ++++++++++---------- leancloud/files_test.go | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/leancloud/encoding.go b/leancloud/encoding.go index 24e5573..97449e4 100644 --- a/leancloud/encoding.go +++ b/leancloud/encoding.go @@ -333,7 +333,7 @@ func encodeFile(file *File, embedded bool) map[string]interface{} { "__type": "File", "name": file.Name, "mime_type": file.MIME, - "metaData": file.Meatadata, + "metaData": file.MetaData, } } diff --git a/leancloud/file.go b/leancloud/file.go index 6de95cf..6ef7e22 100644 --- a/leancloud/file.go +++ b/leancloud/file.go @@ -15,14 +15,14 @@ import ( type File struct { Object - Key string `json:"key"` - Name string `json:"name"` - Provider string `json:"provider"` - Bucket string `json:"bucket"` - MIME string `json:"mime_type"` - URL string `json:"url"` - Size int64 `json:"size"` - Meatadata map[string]interface{} `json:"metadata"` + Key string `json:"key"` + Name string `json:"name"` + Provider string `json:"provider"` + Bucket string `json:"bucket"` + MIME string `json:"mime_type"` + URL string `json:"url"` + Size int64 `json:"size"` + MetaData map[string]interface{} `json:"metadata"` } func (file *File) fetchOwner(client *Client, authOptions ...AuthOption) (*User, error) { diff --git a/leancloud/files.go b/leancloud/files.go index 5116b7e..7c74472 100644 --- a/leancloud/files.go +++ b/leancloud/files.go @@ -42,14 +42,14 @@ func (ref *Files) Upload(file *File, reader io.ReadSeeker, authOptions ...AuthOp file.Size = size } - if reflect.ValueOf(file.Meatadata).IsNil() { - file.Meatadata = make(map[string]interface{}) + if reflect.ValueOf(file.MetaData).IsNil() { + file.MetaData = make(map[string]interface{}) } - file.Meatadata["size"] = file.Size + file.MetaData["size"] = file.Size if owner != nil { - file.Meatadata["owner"] = owner.ID + file.MetaData["owner"] = owner.ID } else { - file.Meatadata["owner"] = "unknown" + file.MetaData["owner"] = "unknown" } token, uploadURL, err := file.fetchToken(ref.c, authOptions...) @@ -90,18 +90,18 @@ func (ref *Files) Upload(file *File, reader io.ReadSeeker, authOptions ...AuthOp // UploadFromURL create an object of file in _File class with given file's url func (ref *Files) UploadFromURL(file *File, authOptions ...AuthOption) error { - if reflect.ValueOf(file.Meatadata).IsNil() { - file.Meatadata = make(map[string]interface{}) + if reflect.ValueOf(file.MetaData).IsNil() { + file.MetaData = make(map[string]interface{}) } owner, err := file.fetchOwner(ref.c, authOptions...) if err != nil { return fmt.Errorf("unexpected error when fetch owner: %v", err) } - file.Meatadata["__source"] = "external" + file.MetaData["__source"] = "external" if owner != nil { - file.Meatadata["owner"] = owner.ID + file.MetaData["owner"] = owner.ID } else { - file.Meatadata["owner"] = "unknown" + file.MetaData["owner"] = "unknown" } path := "/1.1/files" diff --git a/leancloud/files_test.go b/leancloud/files_test.go index ee77e69..1ae6fda 100644 --- a/leancloud/files_test.go +++ b/leancloud/files_test.go @@ -139,7 +139,7 @@ func TestFilesUploadFromFile(t *testing.T) { defer os.Remove(filename) file := &File{ - Meatadata: map[string]interface{}{ + MetaData: map[string]interface{}{ "comment": "This is a comment of Metadata", }, }