Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
c598673b
Commit
c598673b
authored
Nov 17, 2014
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/http: Documented MultiFileReader
parent
5614234d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
commands/http/multifilereader.go
commands/http/multifilereader.go
+7
-0
No files found.
commands/http/multifilereader.go
View file @
c598673b
...
...
@@ -10,6 +10,9 @@ import (
cmds
"github.com/jbenet/go-ipfs/commands"
)
// MultiFileReader reads from a `commands.File` (which can be a directory of files
// or a regular file) as HTTP multipart encoded data.
// WARNING: Not thread-safe!
type
MultiFileReader
struct
{
io
.
Reader
...
...
@@ -24,6 +27,9 @@ type MultiFileReader struct {
form
bool
}
// NewMultiFileReader constructs a MultiFileReader. `file` can be any `commands.File`.
// If `form` is set to true, the multipart data will have a Content-Type of 'multipart/form-data',
// if `form` is false, the Content-Type will be 'multipart/mixed'.
func
NewMultiFileReader
(
file
cmds
.
File
,
form
bool
)
*
MultiFileReader
{
mfr
:=
&
MultiFileReader
{
files
:
file
,
...
...
@@ -103,6 +109,7 @@ func (mfr *MultiFileReader) Read(buf []byte) (written int, err error) {
return
written
,
err
}
// Boundary returns the boundary string to be used to separate files in the multipart data
func
(
mfr
*
MultiFileReader
)
Boundary
()
string
{
return
mfr
.
mpWriter
.
Boundary
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment