good morning!!!!
Skip to content
GitLab
Explore
Sign in
Commits on Source (1)
fix file uploading
· d2e1bd72
Garet Halliday
authored
Apr 14, 2022
d2e1bd72
Hide whitespace changes
Inline
Side-by-side
filing/api_weed/formdata.go
View file @
d2e1bd72
...
...
@@ -11,19 +11,20 @@ import (
func
makeFormData
(
filename
,
mimeType
string
,
content
[]
byte
,
)
(
formData
*
bytes
.
Buffer
,
err
error
)
{
)
(
formData
*
bytes
.
Buffer
,
contentType
string
,
err
error
)
{
buf
:=
new
(
bytes
.
Buffer
)
writer
:=
multipart
.
NewWriter
(
buf
)
defer
writer
.
Close
()
part
,
err
:=
createFormFile
(
writer
,
"file"
,
filename
,
mimeType
)
if
err
!=
nil
{
return
buf
,
err
return
buf
,
contentType
,
err
}
_
,
err
=
part
.
Write
(
content
)
if
err
!=
nil
{
return
buf
,
err
return
buf
,
contentType
,
err
}
return
buf
,
err
contentType
=
writer
.
FormDataContentType
()
return
buf
,
contentType
,
err
}
func
createFormFile
(
writer
*
multipart
.
Writer
,
fieldname
,
filename
,
mime
string
)
(
io
.
Writer
,
error
)
{
...
...
filing/api_weed/weed_api.go
View file @
d2e1bd72
...
...
@@ -88,7 +88,7 @@ func (F *Client) Push(
contentType
=
http
.
DetectContentType
(
dat
)
}
sum
:=
meow
.
Checksum64
(
constants
.
THREEBEEF
,
dat
)
d
,
err
:=
makeFormData
(
normalizeName
(
file
),
contentType
,
dat
)
d
,
contentType
,
err
:=
makeFormData
(
normalizeName
(
file
),
contentType
,
dat
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
filing/fs_weed/weed.go
View file @
d2e1bd72
...
...
@@ -67,12 +67,12 @@ func (O *FS) Open(name string) (filing.HashedFile, error) {
}
meta
,
err
:=
O
.
c
.
Meta
(
out
.
path
+
"?metadata=true"
)
if
err
!=
nil
{
return
nil
,
err
return
out
,
err
}
if
fl
,
ok
:=
meta
.
Sys
()
.
(
*
api_weed
.
WeedFileMeta
);
ok
{
out
.
hash
,
err
=
strconv
.
ParseUint
(
fl
.
Extended
.
Meow64
,
10
,
64
)
if
err
!=
nil
{
return
nil
,
err
return
out
,
err
}
}
return
out
,
nil
...
...