SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
filer: added QR code to transfer files with mobile devices
Chris Lu9b0e8ef026cd
diff --git a/go.mod b/go.modindex 2158cfb65c..2a65d47a13 100644--- a/go.mod+++ b/go.mod@@ -60,6 +60,7 @@ require (github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 // indirectgithub.com/seaweedfs/fuse v0.0.0-20190510212405-310228904effgithub.com/seaweedfs/goexif v1.0.2+ github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686egithub.com/spaolacci/murmur3 v1.1.0 // indirectgithub.com/spf13/afero v1.2.2 // indirectgithub.com/spf13/jwalterweatherman v1.1.0 // indirectdiff --git a/go.sum b/go.sumindex 3ac47ec22d..ce8ff4a8c5 100644--- a/go.sum+++ b/go.sum@@ -452,6 +452,8 @@ github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxgithub.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=+github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=+github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=github.com/smartystreets/gunit v1.3.4/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak=diff --git a/weed/server/filer_server_handlers_read_dir.go b/weed/server/filer_server_handlers_read_dir.goindex 9ca0209f4a..99345550c1 100644--- a/weed/server/filer_server_handlers_read_dir.go+++ b/weed/server/filer_server_handlers_read_dir.go@@ -2,6 +2,9 @@ package weed_serverimport ("context"+ "encoding/base64"+ "fmt"+ "github.com/skip2/go-qrcode""net/http""strconv""strings"@@ -65,21 +68,30 @@ func (fs *FilerServer) listDirectoryHandler(w http.ResponseWriter, r *http.RequelastFileName,shouldDisplayLoadMore,})- } else {- ui.StatusTpl.Execute(w, struct {- Path string- Breadcrumbs []ui.Breadcrumb- Entries interface{}- Limit int- LastFileName string- ShouldDisplayLoadMore bool- }{- path,- ui.ToBreadcrumb(path),- entries,- limit,- lastFileName,- shouldDisplayLoadMore,- })+ return+ }++ var qrImageString string+ img, err := qrcode.Encode(fmt.Sprintf("http://%s:%d%s", fs.option.Host, fs.option.Port, r.URL.Path), qrcode.Medium, 128)+ if err == nil {+ qrImageString = base64.StdEncoding.EncodeToString(img)}++ ui.StatusTpl.Execute(w, struct {+ Path string+ Breadcrumbs []ui.Breadcrumb+ Entries interface{}+ Limit int+ LastFileName string+ ShouldDisplayLoadMore bool+ QrImage string+ }{+ path,+ ui.ToBreadcrumb(path),+ entries,+ limit,+ lastFileName,+ shouldDisplayLoadMore,+ qrImageString,+ })}diff --git a/weed/server/filer_ui/templates.go b/weed/server/filer_ui/templates.goindex 04a81433bd..f86dde5b1f 100644--- a/weed/server/filer_ui/templates.go+++ b/weed/server/filer_ui/templates.go@@ -21,9 +21,11 @@ var funcMap = template.FuncMap{var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOCTYPE html><html><head>- <title>SeaweedFS Filer</title>- <link rel="stylesheet" href="/seaweedfsstatic/bootstrap/3.3.1/css/bootstrap.min.css">+ <title>SeaweedFS Filer</title>+ <meta name="viewport" content="width=device-width, initial-scale=1">+ <link rel="stylesheet" href="/seaweedfsstatic/bootstrap/3.3.1/css/bootstrap.min.css"><style>+body { padding-bottom: 70px; }#drop-area {border: 1px transparent;}@@ -46,6 +48,11 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC#fileElem {display: none;}+.qrImage {+ display: block;+ margin-left: auto;+ margin-right: auto;+}</style></head><body>@@ -116,6 +123,14 @@ var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOC</a></div>{{end}}++ <br/>+ <br/>++ <div class="navbar navbar-fixed-bottom">+ <img src="data:image/png;base64,{{.QrImage}}" class="qrImage" />+ </div>+</div></body><script type="text/javascript">