mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-11-26 22:20:18 +01:00
go fmt
This commit is contained in:
parent
4f637def86
commit
0605b8e271
4 changed files with 29 additions and 35 deletions
|
@ -271,7 +271,6 @@ func New() *Cmd {
|
|||
options = append(options, server.HttpAuthCredentials(httpAuthUser, httpAuthPass))
|
||||
}
|
||||
|
||||
|
||||
switch provider := c.String("provider"); provider {
|
||||
case "s3":
|
||||
if accessKey := c.String("aws-access-key"); accessKey == "" {
|
||||
|
|
|
@ -59,8 +59,8 @@ import (
|
|||
"github.com/gorilla/mux"
|
||||
"github.com/russross/blackfriday"
|
||||
|
||||
qrcode "github.com/skip2/go-qrcode"
|
||||
"encoding/base64"
|
||||
qrcode "github.com/skip2/go-qrcode"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -326,7 +326,7 @@ func MetadataForRequest(contentType string, r *http.Request) Metadata {
|
|||
MaxDate: time.Now().Add(time.Hour * 24 * 365 * 10),
|
||||
Downloads: 0,
|
||||
MaxDownloads: 99999999,
|
||||
DeletionToken: Encode(10000000 + int64(rand.Intn(1000000000))) + Encode(10000000 + int64(rand.Intn(1000000000))),
|
||||
DeletionToken: Encode(10000000+int64(rand.Intn(1000000000))) + Encode(10000000+int64(rand.Intn(1000000000))),
|
||||
}
|
||||
|
||||
if v := r.Header.Get("Max-Downloads"); v == "" {
|
||||
|
@ -439,7 +439,7 @@ func (s *Server) putHandler(w http.ResponseWriter, r *http.Request) {
|
|||
w.Header().Set("Content-Type", "text/plain")
|
||||
|
||||
relativeURL, _ := url.Parse(path.Join(token, filename))
|
||||
deleteUrl , _ := url.Parse(path.Join(token, filename, metadata.DeletionToken))
|
||||
deleteUrl, _ := url.Parse(path.Join(token, filename, metadata.DeletionToken))
|
||||
|
||||
w.Header().Set("X-Url-Delete", resolveUrl(r, deleteUrl, true))
|
||||
|
||||
|
|
|
@ -203,7 +203,6 @@ func TLSConfig(cert, pk string) OptionFn {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func HttpAuthCredentials(user string, pass string) OptionFn {
|
||||
return func(srvr *Server) {
|
||||
srvr.AuthUser = user
|
||||
|
|
|
@ -11,16 +11,16 @@ import (
|
|||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/goamz/goamz/s3"
|
||||
"encoding/json"
|
||||
"github.com/goamz/goamz/s3"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/google"
|
||||
"google.golang.org/api/drive/v3"
|
||||
"google.golang.org/api/googleapi"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Storage interface {
|
||||
|
@ -83,10 +83,10 @@ func (s *LocalStorage) Get(token string, filename string) (reader io.ReadCloser,
|
|||
|
||||
func (s *LocalStorage) Delete(token string, filename string) (err error) {
|
||||
metadata := filepath.Join(s.basedir, token, fmt.Sprintf("%s.metadata", filename))
|
||||
os.Remove(metadata);
|
||||
os.Remove(metadata)
|
||||
|
||||
path := filepath.Join(s.basedir, token, filename)
|
||||
err = os.Remove(path);
|
||||
err = os.Remove(path)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ func NewGDriveStorage(clientJsonFilepath string, localConfigPath string, basedir
|
|||
return nil, err
|
||||
}
|
||||
|
||||
storage := &GDrive{service: srv, basedir: basedir, rootId: "", localConfigPath:localConfigPath}
|
||||
storage := &GDrive{service: srv, basedir: basedir, rootId: "", localConfigPath: localConfigPath}
|
||||
err = storage.setupRoot()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -386,7 +386,7 @@ func (s *GDrive) hasChecksum(f *drive.File) bool {
|
|||
return f.Md5Checksum != ""
|
||||
}
|
||||
|
||||
func (s *GDrive) list(nextPageToken string, q string) (*drive.FileList, error){
|
||||
func (s *GDrive) list(nextPageToken string, q string) (*drive.FileList, error) {
|
||||
return s.service.Files.List().Fields("nextPageToken, files(id, name, mimeType)").Q(q).PageToken(nextPageToken).Do()
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,6 @@ func (s *GDrive) findId(filename string, token string) (string, error) {
|
|||
l, err = s.list(l.NextPageToken, q)
|
||||
}
|
||||
|
||||
|
||||
if fileId == "" {
|
||||
return "", fmt.Errorf("Cannot find file %s/%s", token, filename)
|
||||
}
|
||||
|
@ -484,7 +483,6 @@ func (s *GDrive) Get(token string, filename string) (reader io.ReadCloser, conte
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
contentLength = uint64(fi.Size)
|
||||
contentType = fi.MimeType
|
||||
|
||||
|
@ -534,7 +532,6 @@ func (s *GDrive) Put(token string, filename string, reader io.Reader, contentTyp
|
|||
return err
|
||||
}
|
||||
|
||||
|
||||
if dirId == "" {
|
||||
dir := &drive.File{
|
||||
Name: token,
|
||||
|
@ -567,7 +564,6 @@ func (s *GDrive) Put(token string, filename string, reader io.Reader, contentTyp
|
|||
return nil
|
||||
}
|
||||
|
||||
|
||||
// Retrieve a token, saves the token, then returns the generated client.
|
||||
func getGDriveClient(config *oauth2.Config) *http.Client {
|
||||
tokenFile := "token.json"
|
||||
|
|
Loading…
Reference in a new issue