https://github.com/mushroomsir/httpfile
Upload and Download file by http
https://github.com/mushroomsir/httpfile
easy-to-use formdata
Last synced: 2 months ago
JSON representation
Upload and Download file by http
- Host: GitHub
- URL: https://github.com/mushroomsir/httpfile
- Owner: mushroomsir
- License: mit
- Created: 2017-08-21T09:14:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-18T06:22:57.000Z (about 8 years ago)
- Last Synced: 2024-06-20T11:11:25.776Z (almost 2 years ago)
- Topics: easy-to-use, formdata
- Language: Go
- Homepage:
- Size: 157 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpfile
[](https://travis-ci.org/mushroomsir/httpfile)
[](https://coveralls.io/github/mushroomsir/httpfile?branch=master)
[](https://github.com/mushroomsir/httpfile/blob/master/LICENSE)
[](http://godoc.org/github.com/mushroomsir/httpfile)
## Features
- Easy to use
- Upload file by http FormFata
- Upload file by http Stream
- Download file to local
## Installation
```sh
go get -u github.com/mushroomsir/httpfile
```
## Usage
```go
func TestHTTPFile(t *testing.T) {
require := require.New(t)
res := httpfile.NewReq(fileURL(), "testdata/test.gif").Upload()
require.Nil(res.Error())
require.Equal(200, res.StatusCode())
res = httpfile.NewReq(fileURL(), "testdata/download/test1.gif").SetHeader("filename", "test.gif").Download()
require.Nil(res.Error())
require.Equal(200, res.StatusCode())
require.Equal("bytes", res.GetHeader("Accept-Ranges"))
}
```
## Licenses
All source code is licensed under the [MIT License](https://github.com/mushroomsir/httpfile/blob/master/LICENSE).