File management for Golang
go get github.com/prongbang/filex
- New FileX
fileX := filex.New()
- Make Directory
isSuccess := fileX.Mkdir("public/thumbnail")
- Create Image from Bytes Array
imgPath := "public/thumbnail/image.jpeg"
imgByte := []byte("mock image byte array")
fileX.CreateImage(imgByte, imgPath)
- Create File from Multipart
path := "public/thumbnail"
filename := "image.jpeg"
var file *multipart.FileHeader = mockFile
pathFile, err := fileX.CreateMultipart(path, filename, file)
- Delete file
path, err := fileX.Delete(imgPath)
- Delete directory
err := fileX.DeleteDir("dir")