1
0
mirror of https://github.com/dutchcoders/transfer.sh.git synced 2020-11-18 19:53:40 -08:00
This commit is contained in:
Andrea Spacca 2018-07-07 20:23:50 +02:00
parent 4f637def86
commit 0605b8e271
4 changed files with 29 additions and 35 deletions

View File

@ -271,7 +271,6 @@ func New() *Cmd {
options = append(options, server.HttpAuthCredentials(httpAuthUser, httpAuthPass)) options = append(options, server.HttpAuthCredentials(httpAuthUser, httpAuthPass))
} }
switch provider := c.String("provider"); provider { switch provider := c.String("provider"); provider {
case "s3": case "s3":
if accessKey := c.String("aws-access-key"); accessKey == "" { if accessKey := c.String("aws-access-key"); accessKey == "" {

View File

@ -59,8 +59,8 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/russross/blackfriday" "github.com/russross/blackfriday"
qrcode "github.com/skip2/go-qrcode"
"encoding/base64" "encoding/base64"
qrcode "github.com/skip2/go-qrcode"
) )
var ( var (

View File

@ -203,7 +203,6 @@ func TLSConfig(cert, pk string) OptionFn {
} }
} }
func HttpAuthCredentials(user string, pass string) OptionFn { func HttpAuthCredentials(user string, pass string) OptionFn {
return func(srvr *Server) { return func(srvr *Server) {
srvr.AuthUser = user srvr.AuthUser = user

View File

@ -11,16 +11,16 @@ import (
"strconv" "strconv"
"sync" "sync"
"github.com/goamz/goamz/s3"
"encoding/json" "encoding/json"
"github.com/goamz/goamz/s3"
"golang.org/x/oauth2"
"golang.org/x/net/context" "golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google" "golang.org/x/oauth2/google"
"google.golang.org/api/drive/v3" "google.golang.org/api/drive/v3"
"google.golang.org/api/googleapi" "google.golang.org/api/googleapi"
"net/http"
"io/ioutil" "io/ioutil"
"net/http"
) )
type Storage interface { 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) { func (s *LocalStorage) Delete(token string, filename string) (err error) {
metadata := filepath.Join(s.basedir, token, fmt.Sprintf("%s.metadata", filename)) metadata := filepath.Join(s.basedir, token, fmt.Sprintf("%s.metadata", filename))
os.Remove(metadata); os.Remove(metadata)
path := filepath.Join(s.basedir, token, filename) path := filepath.Join(s.basedir, token, filename)
err = os.Remove(path); err = os.Remove(path)
return return
} }
@ -439,7 +439,6 @@ func (s *GDrive) findId(filename string, token string) (string, error) {
l, err = s.list(l.NextPageToken, q) l, err = s.list(l.NextPageToken, q)
} }
if fileId == "" { if fileId == "" {
return "", fmt.Errorf("Cannot find file %s/%s", token, filename) 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 return
} }
contentLength = uint64(fi.Size) contentLength = uint64(fi.Size)
contentType = fi.MimeType contentType = fi.MimeType
@ -534,7 +532,6 @@ func (s *GDrive) Put(token string, filename string, reader io.Reader, contentTyp
return err return err
} }
if dirId == "" { if dirId == "" {
dir := &drive.File{ dir := &drive.File{
Name: token, Name: token,
@ -567,7 +564,6 @@ func (s *GDrive) Put(token string, filename string, reader io.Reader, contentTyp
return nil return nil
} }
// Retrieve a token, saves the token, then returns the generated client. // Retrieve a token, saves the token, then returns the generated client.
func getGDriveClient(config *oauth2.Config) *http.Client { func getGDriveClient(config *oauth2.Config) *http.Client {
tokenFile := "token.json" tokenFile := "token.json"