mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-11-27 06:30:19 +01:00
cr fixes and dynamic upload size in UI
This commit is contained in:
parent
88003018e6
commit
3ea4ffd0e3
4 changed files with 38 additions and 4 deletions
2
go.mod
2
go.mod
|
@ -11,7 +11,7 @@ require (
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
|
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
|
||||||
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
|
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
|
||||||
github.com/dutchcoders/go-virustotal v0.0.0-20140923143438-24cc8e6fa329
|
github.com/dutchcoders/go-virustotal v0.0.0-20140923143438-24cc8e6fa329
|
||||||
github.com/dutchcoders/transfer.sh-web v0.0.0-20210717081259-8b8af59a0fae
|
github.com/dutchcoders/transfer.sh-web v0.0.0-20210723091746-c17d678a22f3
|
||||||
github.com/elazarl/go-bindata-assetfs v1.0.1
|
github.com/elazarl/go-bindata-assetfs v1.0.1
|
||||||
github.com/fatih/color v1.10.0
|
github.com/fatih/color v1.10.0
|
||||||
github.com/garyburd/redigo v1.6.2 // indirect
|
github.com/garyburd/redigo v1.6.2 // indirect
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -94,6 +94,8 @@ github.com/dutchcoders/transfer.sh-web v0.0.0-20210212072623-ac7014a9c3a7 h1:zKJ
|
||||||
github.com/dutchcoders/transfer.sh-web v0.0.0-20210212072623-ac7014a9c3a7/go.mod h1:jTzXZabwihvQgvmySgD4f4GNszimkXK3o8x1ucH1z5Q=
|
github.com/dutchcoders/transfer.sh-web v0.0.0-20210212072623-ac7014a9c3a7/go.mod h1:jTzXZabwihvQgvmySgD4f4GNszimkXK3o8x1ucH1z5Q=
|
||||||
github.com/dutchcoders/transfer.sh-web v0.0.0-20210717081259-8b8af59a0fae h1:JalbO1PKAsbSYQBW6Q4aXbgj2w4bWofdrHxRRwqRgDc=
|
github.com/dutchcoders/transfer.sh-web v0.0.0-20210717081259-8b8af59a0fae h1:JalbO1PKAsbSYQBW6Q4aXbgj2w4bWofdrHxRRwqRgDc=
|
||||||
github.com/dutchcoders/transfer.sh-web v0.0.0-20210717081259-8b8af59a0fae/go.mod h1:F6Q37CxDh2MHr5KXkcZmNB3tdkK7v+bgE+OpBY+9ilI=
|
github.com/dutchcoders/transfer.sh-web v0.0.0-20210717081259-8b8af59a0fae/go.mod h1:F6Q37CxDh2MHr5KXkcZmNB3tdkK7v+bgE+OpBY+9ilI=
|
||||||
|
github.com/dutchcoders/transfer.sh-web v0.0.0-20210723091746-c17d678a22f3 h1:CM9FGBPXLXhvKo0TuO4CKKdZLah6esP1SAfPzZDjEB0=
|
||||||
|
github.com/dutchcoders/transfer.sh-web v0.0.0-20210723091746-c17d678a22f3/go.mod h1:F6Q37CxDh2MHr5KXkcZmNB3tdkK7v+bgE+OpBY+9ilI=
|
||||||
github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw=
|
github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw=
|
||||||
github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
|
|
@ -238,6 +238,11 @@ func (s *Server) viewHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
hostname := getURL(r, s.proxyPort).Host
|
hostname := getURL(r, s.proxyPort).Host
|
||||||
webAddress := resolveWebAddress(r, s.proxyPath, s.proxyPort)
|
webAddress := resolveWebAddress(r, s.proxyPath, s.proxyPort)
|
||||||
|
|
||||||
|
maxUploadSize := ""
|
||||||
|
if s.maxUploadSize > 0 {
|
||||||
|
maxUploadSize = formatSize(s.maxUploadSize)
|
||||||
|
}
|
||||||
|
|
||||||
purgeTime := ""
|
purgeTime := ""
|
||||||
if s.purgeDays > 0 {
|
if s.purgeDays > 0 {
|
||||||
purgeTime = s.purgeDays.String()
|
purgeTime = s.purgeDays.String()
|
||||||
|
@ -249,6 +254,7 @@ func (s *Server) viewHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
GAKey string
|
GAKey string
|
||||||
UserVoiceKey string
|
UserVoiceKey string
|
||||||
PurgeTime string
|
PurgeTime string
|
||||||
|
MaxUploadSize string
|
||||||
SampleToken string
|
SampleToken string
|
||||||
SampleToken2 string
|
SampleToken2 string
|
||||||
}{
|
}{
|
||||||
|
@ -257,6 +263,7 @@ func (s *Server) viewHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
s.gaKey,
|
s.gaKey,
|
||||||
s.userVoiceKey,
|
s.userVoiceKey,
|
||||||
purgeTime,
|
purgeTime,
|
||||||
|
maxUploadSize,
|
||||||
Token(s.randomTokenLength),
|
Token(s.randomTokenLength),
|
||||||
Token(s.randomTokenLength),
|
Token(s.randomTokenLength),
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ THE SOFTWARE.
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
|
@ -49,7 +50,6 @@ func getAwsSession(accessKey, secretKey, region, endpoint string, forcePathStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatNumber(format string, s uint64) string {
|
func formatNumber(format string, s uint64) string {
|
||||||
|
|
||||||
return RenderFloat(format, float64(s))
|
return RenderFloat(format, float64(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,3 +255,28 @@ func acceptsHTML(hdr http.Header) bool {
|
||||||
|
|
||||||
return (false)
|
return (false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func formatSize(size int64) string {
|
||||||
|
sizeFloat := float64(size)
|
||||||
|
base := math.Log(sizeFloat)/math.Log(1024)
|
||||||
|
|
||||||
|
sizeOn := math.Pow(1024, base - math.Floor(base))
|
||||||
|
|
||||||
|
var round float64
|
||||||
|
pow := math.Pow(10, float64(2))
|
||||||
|
digit := pow * sizeOn
|
||||||
|
round = math.Floor(digit)
|
||||||
|
|
||||||
|
newVal := round / pow
|
||||||
|
|
||||||
|
var suffixes [5]string
|
||||||
|
suffixes[0] = "B"
|
||||||
|
suffixes[1] = "KB"
|
||||||
|
suffixes[2] = "MB"
|
||||||
|
suffixes[3] = "GB"
|
||||||
|
suffixes[4] = "TB"
|
||||||
|
|
||||||
|
|
||||||
|
getSuffix := suffixes[int(math.Floor(base))]
|
||||||
|
return fmt.Sprintf("%s %s", strconv.FormatFloat(newVal, 'f', -1, 64), getSuffix)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue