Skip to content

Multipartstream offers multipart/form-data body requests as stream object, avoiding overheads on upload processes.

License

Notifications You must be signed in to change notification settings

isaquecsilva/multipartstream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultipartStream

Multipartstream offers multipart/form-data body requests as stream object, avoiding overheads on upload processes by larger files.

Its currently under development, so there's no garrantees of stability or backwards compatibility.

Installation

go get github.com/isaquecsilva/multipartstream

Example Usage:

package main

import (
    "os"
    "strings"
    "net/http"

    ms "github.com/isaquecsilva/multipartstream"
)

func main() {
    // new multipartStream instance
    form := ms.NewMultipartStream()

    // adding a new form field called 'sender'
    form.FormField("sender", strings.NewReader("Herold"))
    
    // loading file to upload
    example, err := os.Open("example.txt")
    if err != nil {
        panic(err)
    }
    defer example.Close()

    // adding our example.txt file, and checking for mimetypes errors.
    if err = form.FormFile("file", "example.txt", example); err != nil {
    	panic(err)
    }

    // adding trailing boundary signaling multipart/form-data body end.
    form.Done()

    // our http request    
    req, _ := http.NewRequest(http.MethodPost, endpoint, form)

    // sending request
    http.DefaultClient.Do(req)
}

Inspiration

It was inspired on famous Go package technoweenie/multipartstreamer

License

  • Terms of use for Multipartstream resides under MIT license.

About

Multipartstream offers multipart/form-data body requests as stream object, avoiding overheads on upload processes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published