https://github.com/vanng822/uploader
Image uploader
https://github.com/vanng822/uploader
Last synced: 9 months ago
JSON representation
Image uploader
- Host: GitHub
- URL: https://github.com/vanng822/uploader
- Owner: vanng822
- License: mit
- Created: 2015-03-06T22:09:15.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-28T19:32:20.000Z (over 10 years ago)
- Last Synced: 2025-04-30T05:48:43.370Z (9 months ago)
- Language: Go
- Homepage:
- Size: 352 KB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uploader
Upload image to storage, retrieve and delete.
Bundle with File storage but any storage implements
ImageStorage should works, please create pull request
if you implement one.
## http request methods
### GET
for getting image
### POST/PUT
for creating new image
### DELETE
for deleting an image
## Examle
Take look in "app" if you want something more ready to run
package main
import (
"github.com/vanng822/uploader"
"net/http"
)
func main() {
storage := uploader.NewImageStorageFile("./data")
u := uploader.NewUploader(storage)
handler := uploader.UploadHandler(u, "file", "filename")
http.HandleFunc("/upload", handler)
http.ListenAndServe(":8080", nil)
}
// curl -i -X POST -F file=@data/kth.jpg http://127.0.0.1:8080/upload
// curl -i -X PUT -F file=@data/kth.jpg http://127.0.0.1:8080/upload?filename=40a0eb02-1e16-44e2-4694-2db2c159d452.jpg
// curl -i http://127.0.0.1:8080/upload?filename=40a0eb02-1e16-44e2-4694-2db2c159d452.jpg