mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2020-11-18 19:53:40 -08:00
updated readme & go formatted code
This commit is contained in:
parent
16ad1833d2
commit
b8eaf23805
@ -1,6 +1,8 @@
|
||||
# transfer.sh
|
||||
|
||||
Easy and fast file sharing from the command-line. This code contains the server with everything you need to create your own instance. Transfer.sh currently runs on top of Amazon S3. Other storage types will be added shortly.
|
||||
Easy and fast file sharing from the command-line. This code contains the server with everything you need to create your own instance.
|
||||
|
||||
Transfer.sh support currently the s3 (Amazon S3) provider and local file system (local).
|
||||
|
||||
[](https://travis-ci.org/dutchcoders/transfer.sh)
|
||||
|
||||
|
@ -38,19 +38,19 @@ import (
|
||||
"github.com/golang/gddo/httputil/header"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/kennygrant/sanitize"
|
||||
html_template "html/template"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"log"
|
||||
"math/rand"
|
||||
"mime"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
html_template "html/template"
|
||||
text_template "text/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
func healthHandler(w http.ResponseWriter, r *http.Request) {
|
||||
@ -275,7 +275,7 @@ func putHandler(w http.ResponseWriter, r *http.Request) {
|
||||
contentType = mime.TypeByExtension(filepath.Ext(vars["filename"]))
|
||||
}
|
||||
|
||||
token := Encode(10000000+int64(rand.Intn(1000000000)))
|
||||
token := Encode(10000000 + int64(rand.Intn(1000000000)))
|
||||
|
||||
log.Printf("Uploading %s %d %s", token, filename, contentLength, contentType)
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"github.com/goamz/goamz/s3"
|
||||
"strconv"
|
||||
"fmt"
|
||||
"github.com/goamz/goamz/s3"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Storage interface {
|
||||
@ -20,10 +20,9 @@ type LocalStorage struct {
|
||||
}
|
||||
|
||||
func NewLocalStorage(basedir string) (*LocalStorage, error) {
|
||||
return &LocalStorage {basedir: basedir}, nil
|
||||
return &LocalStorage{basedir: basedir}, nil
|
||||
}
|
||||
|
||||
|
||||
func (s *LocalStorage) Get(token string, filename string) (reader io.ReadCloser, contentType string, contentLength uint64, err error) {
|
||||
path := filepath.Join(s.basedir, token, filename)
|
||||
|
||||
@ -78,7 +77,7 @@ func NewS3Storage() (*S3Storage, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &S3Storage {bucket: bucket}, nil
|
||||
return &S3Storage{bucket: bucket}, nil
|
||||
}
|
||||
|
||||
func (s *S3Storage) Get(token string, filename string) (reader io.ReadCloser, contentType string, contentLength uint64, err error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user