File tree 1 file changed +4
-13
lines changed
1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,12 @@ import (
8
8
"mime/multipart"
9
9
"net/http"
10
10
"net/url"
11
- "strings"
12
11
)
13
12
14
13
//上传文件内容
15
14
// fileContentMap的key是文件名,value是文件内容
16
15
//当目标文件存在时,会自动重命名上传
17
- func (lib * Library ) UploadFileContent (parentDir string , fileContentMap map [string ][]byte ) error {
18
- //参数检查
19
- if ! strings .HasSuffix (parentDir , "/" ) {
20
- return fmt .Errorf ("目录%s必须以/结尾" , parentDir )
21
- }
22
-
16
+ func (lib * Library ) UploadFileContent (dir string , fileContentMap map [string ][]byte ) error {
23
17
body := & bytes.Buffer {}
24
18
writer := multipart .NewWriter (body )
25
19
@@ -33,12 +27,9 @@ func (lib *Library) UploadFileContent(parentDir string, fileContentMap map[strin
33
27
}
34
28
35
29
//填充其他字段
36
- writer .WriteField ("parent_dir" , parentDir )
37
-
38
- //FIXME:
39
- //文档中提到使用relative_path,系统会自动创建不存在的路径
40
- //但实际上好像没有效果,所以这里暂不支持这个参数
41
- //writer.WriteField("relative_path", subDir)
30
+ writer .WriteField ("replace" , "1" )
31
+ writer .WriteField ("parent_dir" , "/" )
32
+ writer .WriteField ("relative_path" , dir )
42
33
43
34
err := writer .Close ()
44
35
if err != nil {
You can’t perform that action at this time.
0 commit comments