亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄 搜尋
archive archive/tar archive/zip bufio bufio(緩存) builtin builtin(內(nèi)置包) bytes bytes(包字節(jié)) compress compress/bzip2(壓縮/bzip2) compress/flate(壓縮/flate) compress/gzip(壓縮/gzip) compress/lzw(壓縮/lzw) compress/zlib(壓縮/zlib) container container/heap(容器數(shù)據(jù)結(jié)構(gòu)heap) container/list(容器數(shù)據(jù)結(jié)構(gòu)list) container/ring(容器數(shù)據(jù)結(jié)構(gòu)ring) context context(上下文) crypto crypto(加密) crypto/aes(加密/aes) crypto/cipher(加密/cipher) crypto/des(加密/des) crypto/dsa(加密/dsa) crypto/ecdsa(加密/ecdsa) crypto/elliptic(加密/elliptic) crypto/hmac(加密/hmac) crypto/md5(加密/md5) crypto/rand(加密/rand) crypto/rc4(加密/rc4) crypto/rsa(加密/rsa) crypto/sha1(加密/sha1) crypto/sha256(加密/sha256) crypto/sha512(加密/sha512) crypto/subtle(加密/subtle) crypto/tls(加密/tls) crypto/x509(加密/x509) crypto/x509/pkix(加密/x509/pkix) database database/sql(數(shù)據(jù)庫(kù)/sql) database/sql/driver(數(shù)據(jù)庫(kù)/sql/driver) debug debug/dwarf(調(diào)試/dwarf) debug/elf(調(diào)試/elf) debug/gosym(調(diào)試/gosym) debug/macho(調(diào)試/macho) debug/pe(調(diào)試/pe) debug/plan9obj(調(diào)試/plan9obj) encoding encoding(編碼) encoding/ascii85(編碼/ascii85) encoding/asn1(編碼/asn1) encoding/base32(編碼/base32) encoding/base64(編碼/base64) encoding/binary(編碼/binary) encoding/csv(編碼/csv) encoding/gob(編碼/gob) encoding/hex(編碼/hex) encoding/json(編碼/json) encoding/pem(編碼/pem) encoding/xml(編碼/xml) errors errors(錯(cuò)誤) expvar expvar flag flag(命令行參數(shù)解析flag包) fmt fmt go go/ast(抽象語(yǔ)法樹(shù)) go/build go/constant(常量) go/doc(文檔) go/format(格式) go/importer go/parser go/printer go/scanner(掃描儀) go/token(令牌) go/types(類型) hash hash(散列) hash/adler32 hash/crc32 hash/crc64 hash/fnv html html html/template(模板) image image(圖像) image/color(顏色) image/color/palette(調(diào)色板) image/draw(繪圖) image/gif image/jpeg image/png index index/suffixarray io io io/ioutil log log log/syslog(日志系統(tǒng)) math math math/big math/big math/bits math/bits math/cmplx math/cmplx math/rand math/rand mime mime mime/multipart(多部分) mime/quotedprintable net net net/http net/http net/http/cgi net/http/cookiejar net/http/fcgi net/http/httptest net/http/httptrace net/http/httputil net/http/internal net/http/pprof net/mail net/mail net/rpc net/rpc net/rpc/jsonrpc net/smtp net/smtp net/textproto net/textproto net/url net/url os os os/exec os/signal os/user path path path/filepath(文件路徑) plugin plugin(插件) reflect reflect(反射) regexp regexp(正則表達(dá)式) regexp/syntax runtime runtime(運(yùn)行時(shí)) runtime/debug(調(diào)試) runtime/internal/sys runtime/pprof runtime/race(競(jìng)爭(zhēng)) runtime/trace(執(zhí)行追蹤器) sort sort(排序算法) strconv strconv(轉(zhuǎn)換) strings strings(字符串) sync sync(同步) sync/atomic(原子操作) syscall syscall(系統(tǒng)調(diào)用) testing testing(測(cè)試) testing/iotest testing/quick text text/scanner(掃描文本) text/tabwriter text/template(定義模板) text/template/parse time time(時(shí)間戳) unicode unicode unicode/utf16 unicode/utf8 unsafe unsafe
文字

  • import "mime/multipart"

  • 概述

  • 索引

  • 例子

概述

Package multipart實(shí)現(xiàn)了RFC 2046中定義的MIME多部分解析。

對(duì)于HTTP(RFC 2388)和由流行瀏覽器生成的多部分機(jī)構(gòu)來(lái)說(shuō),這個(gè)實(shí)現(xiàn)就足夠了。

索引

  • 變量

  • type File

  • type FileHeader

  • func (fh *FileHeader) Open() (File, error)

  • type Form

  • func (f *Form) RemoveAll() error

  • type Part

  • func (p *Part) Close() error

  • func (p *Part) FileName() string

  • func (p *Part) FormName() string

  • func (p *Part) Read(d []byte) (n int, err error)

  • type Reader

  • func NewReader(r io.Reader, boundary string) *Reader

  • func (r *Reader) NextPart() (*Part, error)

  • func (r *Reader) ReadForm(maxMemory int64) (*Form, error)

  • type Writer

  • func NewWriter(w io.Writer) *Writer

  • func (w *Writer) Boundary() string

  • func (w *Writer) Close() error

  • func (w *Writer) CreateFormField(fieldname string) (io.Writer, error)

  • func (w *Writer) CreateFormFile(fieldname, filename string) (io.Writer, error)

  • func (w *Writer) CreatePart(header textproto.MIMEHeader) (io.Writer, error)

  • func (w *Writer) FormDataContentType() string

  • func (w *Writer) SetBoundary(boundary string) error

  • func (w *Writer) WriteField(fieldname, value string) error

例子

NewReader

文件包

formdata.go multipart.go writer.go

變量

如果消息表單數(shù)據(jù)太大而無(wú)法處理,則ErrMessageTooLarge由ReadForm返回。

var ErrMessageTooLarge = errors.New("multipart: message too large")

type File

文件是訪問(wèn)多部分消息的文件部分的接口。其內(nèi)容可以存儲(chǔ)在內(nèi)存中或磁盤(pán)上。如果存儲(chǔ)在磁盤(pán)上,則文件的基礎(chǔ)具體類型將是* os.File。

type File interface {
        io.Reader
        io.ReaderAt
        io.Seeker
        io.Closer}

type FileHeader

FileHeader描述多部分請(qǐng)求的文件部分。

type FileHeader struct {
        Filename string
        Header   textproto.MIMEHeader
        Size     int64        // contains filtered or unexported fields}

func (*FileHeader) Open

func (fh *FileHeader) Open() (File, error)

打開(kāi)并返回FileHeader的關(guān)聯(lián)文件。

type Form

表單是一個(gè)解析的多部分表單。它的File部分存儲(chǔ)在內(nèi)存中或磁盤(pán)上,并可通過(guò)* FileHeader的Open方法訪問(wèn)。其Value部分以字符串形式存儲(chǔ)。兩者都以字段名稱為關(guān)鍵字。

type Form struct {
        Value map[string][]string
        File  map[string][]*FileHeader}

func (*Form) RemoveAll

func (f *Form) RemoveAll() error

RemoveAll刪除與表單關(guān)聯(lián)的所有臨時(shí)文件。

type Part

零件表示多部分機(jī)構(gòu)中的單個(gè)零件。

type Part struct {        // The headers of the body, if any, with the keys canonicalized        // in the same fashion that the Go http.Request headers are.        // For example, "foo-bar" changes case to "Foo-Bar"        //        // As a special case, if the "Content-Transfer-Encoding" header        // has a value of "quoted-printable", that header is instead        // hidden from this map and the body is transparently decoded        // during Read calls.
        Header textproto.MIMEHeader        // contains filtered or unexported fields}

func (*Part) Close

func (p *Part) Close() error

func (*Part) FileName

func (p *Part) FileName() string

FileName返回零件的Content-Disposition標(biāo)題的文件名參數(shù)。

func (*Part) FormName

func (p *Part) FormName() string

如果p有一個(gè)類型為“form-data”的Content-Disposition,F(xiàn)ormName將返回name參數(shù)。否則,它返回空字符串。

func (*Part) Read

func (p *Part) Read(d []byte) (n int, err error)

Read讀取零件的正文,在其標(biāo)題之后和下一部分(如果有)開(kāi)始之前。

type Reader

Reader是MIME多部分主體中的部分迭代器。Reader的底層解析器根據(jù)需要使用它的輸入。尋求不支持。

type Reader struct {        // contains filtered or unexported fields}

func NewReader

func NewReader(r io.Reader, boundary string) *Reader

NewReader使用給定的MIME邊界從r創(chuàng)建新的多部分讀取器讀取。

邊界通常從消息的“Content-Type”頭部的“邊界”參數(shù)獲得。使用mime.ParseMediaType來(lái)解析這些標(biāo)題。

package mainimport ("fmt""io""io/ioutil""log""mime""mime/multipart""net/mail""strings")func main() {
	msg := &mail.Message{
		Header: map[string][]string{"Content-Type": {"multipart/mixed; boundary=foo"},},
		Body: strings.NewReader("--foo\r\nFoo: one\r\n\r\nA section\r\n" +"--foo\r\nFoo: two\r\n\r\nAnd another\r\n" +"--foo--\r\n"),}
	mediaType, params, err := mime.ParseMediaType(msg.Header.Get("Content-Type"))if err != nil {
		log.Fatal(err)}if strings.HasPrefix(mediaType, "multipart/") {
		mr := multipart.NewReader(msg.Body, params["boundary"])for {
			p, err := mr.NextPart()if err == io.EOF {return}if err != nil {
				log.Fatal(err)}
			slurp, err := ioutil.ReadAll(p)if err != nil {
				log.Fatal(err)}
			fmt.Printf("Part %q: %q\n", p.Header.Get("Foo"), slurp)}}}

func (*Reader) NextPart

func (r *Reader) NextPart() (*Part, error)

NextPart返回多部分中的下一部分或錯(cuò)誤。當(dāng)沒(méi)有更多的零件時(shí),返回錯(cuò)誤io.EOF。

func (*Reader) ReadForm

func (r *Reader) ReadForm(maxMemory int64) (*Form, error)

ReadForm解析整個(gè)多部分消息,其部分具有“form-data”的內(nèi)容處置。它在內(nèi)存中存儲(chǔ)最大內(nèi)存字節(jié)數(shù)+ 10MB(為非文件部分保留)。無(wú)法存儲(chǔ)在內(nèi)存中的文件將以臨時(shí)文件的形式存儲(chǔ)在磁盤(pán)上。如果所有非文件部分都不能存儲(chǔ)在內(nèi)存中,它將返回ErrMessageTooLarge。

type Writer

Writer生成多部分消息。

type Writer struct {        // contains filtered or unexported fields}

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter返回一個(gè)新的具有隨機(jī)邊界的多部分寫(xiě)入器,寫(xiě)入w。

func (*Writer) Boundary

func (w *Writer) Boundary() string

Boundary返回 Writer的邊界。

func (*Writer) Close

func (w *Writer) Close() error

關(guān)閉完成多部分消息并將尾部邊界結(jié)束行寫(xiě)入輸出。

func (*Writer) CreateFormField

func (w *Writer) CreateFormField(fieldname string) (io.Writer, error)

CreateFormField使用給定的字段名稱調(diào)用帶有標(biāo)題的CreatePart。

func (*Writer) CreateFormFile

func (w *Writer) CreateFormFile(fieldname, filename string) (io.Writer, error)

CreateFormFile是CreatePart的一個(gè)便捷包裝。它使用提供的字段名稱和文件名創(chuàng)建一個(gè)新的表單數(shù)據(jù)標(biāo)題。

func (*Writer) CreatePart

func (w *Writer) CreatePart(header textproto.MIMEHeader) (io.Writer, error)

CreatePart使用提供的標(biāo)題創(chuàng)建一個(gè)新的多部分部分。該部分的主體應(yīng)寫(xiě)入返回的Writer。調(diào)用CreatePart之后,可能不再寫(xiě)入任何以前的部分。

func (*Writer) FormDataContentType

func (w *Writer) FormDataContentType() string

FormDataContentType返回具有該Writer邊界的HTTP multipart / form-data的Content-Type。

func (*Writer) SetBoundary

func (w *Writer) SetBoundary(boundary string) error

SetBoundary用顯式值覆蓋Writer的默認(rèn)隨機(jī)生成邊界分隔符。

必須在創(chuàng)建任何部件之前調(diào)用SetBoundary,可能只包含某些ASCII字符,并且必須非空且最多70個(gè)字節(jié)。

func (*Writer) WriteField

func (w *Writer) WriteField(fieldname, value string) error

WriteField調(diào)用CreateFormField,然后寫(xiě)入給定的值。

上一篇: 下一篇: