
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
github.com/golangorg/formstash
Advanced tools
▄▄▄▄ ▄▄▄ ██▀███ ▄▄▄ ██ ▄█▀▄▄▄
▓█████▄ ▒████▄ ▓██ ▒ ██▒▒████▄ ██▄█▒▒████▄
▒██▒ ▄██▒██ ▀█▄ ▓██ ░▄█ ▒▒██ ▀█▄ ▓███▄░▒██ ▀█▄
▒██░█▀ ░██▄▄▄▄██ ▒██▀▀█▄ ░██▄▄▄▄██ ▓██ █▄░██▄▄▄▄██
░▓█ ▀█▓ ▓█ ▓██▒░██▓ ▒██▒ ▓█ ▓██▒▒██▒ █▄▓█ ▓██▒
░▒▓███▀▒ ▒▒ ▓▒█░░ ▒▓ ░▒▓░ ▒▒ ▓▒█░▒ ▒▒ ▓▒▒▒ ▓▒█░
▒░▒ ░ ▒ ▒▒ ░ ░▒ ░ ▒░ ▒ ▒▒ ░░ ░▒ ▒░ ▒ ▒▒ ░
░ ░ ░ ▒ ░░ ░ ░ ▒ ░ ░░ ░ ░ ▒
░ ░ ░ ░ ░ ░░ ░ ░ ░
░
a tool for handling file uploads for http servers
makes it easier to make operations with files from the http request.
go get github.com/golangorg/formstash/v2
func main() {
// create a parser
parser := formstash.NewParser(formstash.ParserOptions{
MaxFileSize: 5 << 20,
MaxFileCount: 5,
MaxParseCount: 5,
})
store := formstash.NewFilesystemStorage("./files")
router := gin.Default()
router.POST("/upload", func(c *gin.Context) {
// parse
request, err := parser.Parse(c.Request)
if err != nil {
fmt.Println(err)
}
// get the form
images, err := request.GetForm("images")
if err != nil {
fmt.Println(err)
}
// save
for key, image := range images {
err = store.Save("images", "image_"+strconv.Itoa(key), image)
if err != nil {
fmt.Println(err)
}
}
})
router.Run()
}
You can use formstash with the other http server libraries, just pass the http.Request to the parser.Parse function.
You can filter parts by their properties, like part's content type. Parser can inspect the part's bytes and detect the type of the part with the Inspector.
// create a parser
parser := formstash.NewParser(formstash.ParserOptions{
MaxFileSize: 5 << 20,
MaxFileCount: 5,
MaxParseCount: 5,
})
// give parser an inspector
parser.SetInspector(formstash.NewDefaultInspector(512))
// give parser a filter
parser.SetFilter(formstash.NewExtensionFilter(".jpg"))
Now parser will inspect the each part and it will just return the jpeg ones from the Parse function. You can make your own Inspector and Filter.
Pull requests are welcome. please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.