forked from mark-kubacki/http.upload
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.go
More file actions
32 lines (25 loc) · 747 Bytes
/
example.go
File metadata and controls
32 lines (25 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// This file is released into the public domain.
// +build ignore
// Package main implements a minimal http server that accepts uploads.
//
// For example, this is how you'd upload a file using `curl`:
// go run "this file"
// curl -T /etc/os-release http://127.0.0.1:9000/from-release
package main
import (
"net/http"
"os"
upload "blitznote.com/src/http.upload/v5"
)
func main() {
var scope = "/"
directory := os.TempDir()
if otherTempDir, present := os.LookupEnv("TMPDIR"); present {
directory = otherTempDir
}
next := http.FileServer(http.Dir(directory))
uploadHandler, _ := upload.NewHandler(scope, directory, next)
uploadHandler.EnableWebdav = true
http.Handle(scope, uploadHandler)
http.ListenAndServe(":9000", nil)
}