Documentation
¶
Overview ¶
Package file provides a series of file creation functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MediaType ¶
func MediaType(i interface{}) string
MediaType returns the file's mime type. If the mime type cannot be determined, it returns "application/octet-stream".
The i should be a *os.File, io.Reader, or byte slice.
func NewMultiFileReader ¶
func NewMultiFileReader(path string, form bool) (*files.MultiFileReader, error)
NewMultiFileReader constructs a files.MultiFileReader via github.com/ipfs/go-ipfs-files. `path` can be any `commands.Directory`. If `form` is set to true, the Content-Disposition will be "form-data". Otherwise, it will be "attachment".
It returns an io.Reader and error.
Types ¶
type MultiFileReader ¶
MultiFileReader reads from a `commands.Node` (which can be a directory of files or a regular file) as HTTP multipart encoded data.
func CreateMultiForm ¶
func CreateMultiForm(node *Node, form bool) (mfr *MultiFileReader, err error)
CreateMultiForm constructs a MultiFileReader. `path` should be a Node in serialfile. If `form` is set to true, the Content-Disposition will be "form-data". Otherwise, it will be "attachment".
It returns an io.Reader and error.
Example:
> node, err := file.NewSerialFile("directory-path") > > node.MapDirectory("a-dir-name-show-in-pinning-service")
func (*MultiFileReader) Boundary ¶
func (mfr *MultiFileReader) Boundary() string
Boundary returns the boundary string to be used to separate files in the multipart data
func (*MultiFileReader) Write ¶
func (mfr *MultiFileReader) Write(header textproto.MIMEHeader, content []byte) error
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a serial files.
func NewSerialFile ¶
NewSerialFile adopts serial files and returns a Node represents a file, directory, or special file.
func (*Node) MapDirectory ¶
MapDirectory sets up a new target directory by given path name.