Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rosbit/multipart-creator
A utility to create multipart content that could be used as body of an HTTP POST request or email
https://github.com/rosbit/multipart-creator
email http-post-body multipart
Last synced: about 6 hours ago
JSON representation
A utility to create multipart content that could be used as body of an HTTP POST request or email
- Host: GitHub
- URL: https://github.com/rosbit/multipart-creator
- Owner: rosbit
- Created: 2020-09-20T05:00:29.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-09T06:47:46.000Z (over 3 years ago)
- Last Synced: 2023-07-27T22:35:28.639Z (over 1 year ago)
- Topics: email, http-post-body, multipart
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# multipart creator
Utility to create the mulitpart content that could be used as the body of an HTTP POST request or email.
### Usage
This package is fully go-getable. So just type `go get github.com/rosbit/multipart-creator` to install.
```go
package mainimport (
"github.com/rosbit/multipart-creator"
"fmt"
"os"
"bytes"
)func main() {
// sample 1:
params := []multipart.Param{
multipart.Param{"name", "rosbit", nil},
multipart.Param{"age", 10, nil},
multipart.Param{"file", "this/is/filename", bytes.NewBuffer([]byte("the content of filename"))},
}contentType, err := multipart.Create(os.Stdout, "", params)
// sample 2:
contentType, err := multipart.CreateMultiPart(os.Stdout, "-- this is my boundary --",
multipart.KeyVal("name", "rosbit"),
multipart.KeyVal("age", 10),
multipart.Reader("file", "file/name", bytes.NewBuffer([]byte("the content of optional file name"))),
)// output result
if err != nil {
fmt.Printf("failed to create multipart: %v\n", err)
return
}
fmt.Printf("Content-Type: %s\n", contentType)
}
```### Status
The package is fully tested, so be happy to use it.
### Contribution
Pull requests are welcome! Also, if you want to discuss something send a pull request with proposal and changes.
__Convention:__ fork the repository and make changes on your fork in a feature branch.