diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..a001bf8 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "transfersh-web/bower_components" +} diff --git a/README.md b/README.md index 65e6635..e1f2a70 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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. +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. [![Build Status](https://travis-ci.org/dutchcoders/transfer.sh.svg?branch=master)](https://travis-ci.org/dutchcoders/transfer.sh) @@ -36,10 +36,29 @@ $ transfer test.txt ## Development -- grunt serve -- grunt build +``` +npm install +bower install + +go get github.com/PuerkitoBio/ghost/handlers +go get github.com/gorilla/mux +go get github.com/dutchcoders/go-clamd +go get github.com/goamz/goamz/s3 +go get github.com/goamz/goamz/aws +go get github.com/golang/gddo/httputil/header +go get github.com/kennygrant/sanitize + +grunt serve +grunt build + +sh transfer-server/run.sh +``` + +## Build -- sh transfer-server/run.sh +``` +go build -o transfersh-server *.go +``` ## Contributions @@ -55,4 +74,5 @@ Contributions are welcome. ## Copyright and license -Code and documentation copyright 2011-2014 Remco Verhoef. Code released under [the MIT license](LICENSE). +Code and documentation copyright 2011-2014 Remco Verhoef. +Code released under [the MIT license](LICENSE). diff --git a/bower.json b/bower.json index f59ba0c..901f1b7 100644 --- a/bower.json +++ b/bower.json @@ -16,6 +16,7 @@ "dependencies": { "bootstrap": "~3.0.0", "modernizr": "~2.6.2", + "uri.js": "~1.14.1", "typed.js": "https://github.com/mattboldt/typed.js.git" } } diff --git a/transfersh-server/codec.go b/transfersh-server/codec.go index bd394e5..dfad3f1 100644 --- a/transfersh-server/codec.go +++ b/transfersh-server/codec.go @@ -1,3 +1,26 @@ +/* +https://github.com/fs111/kurz.go/blob/master/src/codec.go + +Copyright (c) 2011 André Kelpe + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + package main import ( diff --git a/transfersh-server/handlers.go b/transfersh-server/handlers.go index b751b54..356fffb 100644 --- a/transfersh-server/handlers.go +++ b/transfersh-server/handlers.go @@ -102,6 +102,7 @@ func viewHandler(w http.ResponseWriter, r *http.Request) { } func notFoundHandler(w http.ResponseWriter, r *http.Request) { + http.Error(w, http.StatusText(404), 404) } func postHandler(w http.ResponseWriter, r *http.Request) { diff --git a/transfersh-server/main.go b/transfersh-server/main.go index 9e95265..0ea2803 100644 --- a/transfersh-server/main.go +++ b/transfersh-server/main.go @@ -69,6 +69,7 @@ func main() { r.PathPrefix("/images/").Handler(http.FileServer(http.Dir("./static/"))) r.PathPrefix("/fonts/").Handler(http.FileServer(http.Dir("./static/"))) r.PathPrefix("/ico/").Handler(http.FileServer(http.Dir("./static/"))) + r.PathPrefix("/favicon.ico").Handler(http.FileServer(http.Dir("./static/"))) r.PathPrefix("/robots.txt").Handler(http.FileServer(http.Dir("./static/"))) r.HandleFunc("/({files:.*}).zip", zipHandler).Methods("GET") @@ -103,7 +104,7 @@ func main() { r.HandleFunc("/{filename}", putHandler).Methods("PUT") r.HandleFunc("/health.html", healthHandler).Methods("GET") r.HandleFunc("/", postHandler).Methods("POST") - r.HandleFunc("/{page}", viewHandler).Methods("GET") + // r.HandleFunc("/{page}", viewHandler).Methods("GET") r.HandleFunc("/", viewHandler).Methods("GET") r.NotFoundHandler = http.HandlerFunc(notFoundHandler) diff --git a/transfersh-server/static/index.html b/transfersh-server/static/index.html index 6e19344..d8c5c7e 100644 --- a/transfersh-server/static/index.html +++ b/transfersh-server/static/index.html @@ -15,8 +15,8 @@ - - + + @@ -130,17 +130,24 @@

Uploading

Uploading is easy using curl.

- curl --upload-file ./hello.txt https://transfer.sh/hello.txt + $ curl --upload-file ./hello.txt https://transfer.sh/hello.txt

Download the file.

- curl --upload-file ./hello.txt https://transfer.sh/hello.txt + $ curl --upload-file ./hello.txt https://transfer.sh/hello.txt

Make an alias

Create an alias, and add it to .bashrc for faster use

- transfer() { curl --upload-file $1 https://transfer.sh/$(basename $1); }
+ $ transfer() { + # write to output to tmpfile because of progress bar + tmpfile=$( mktemp -t transfer ) + curl --progress-bar --upload-file $1 https://transfer.sh/$(basename $1) >> $tmpfile; + cat $tmpfile; + rm -f $tmpfile; +} + alias transfer=transfer

Now you can just use transfer command

- transfer hello.txt + $transfer hello.txt
@@ -149,22 +156,21 @@ alias transfer=transfer

Transfer multiple files

Upload multiple files at once

- curl -i -F filedata=@/tmp/hello.txt -F filedata=@/tmp/hello2.txt https://transfer.sh/ + $ curl -i -F filedata=@/tmp/hello.txt -F filedata=@/tmp/hello2.txt https://transfer.sh/

Combining downloads as zip or tar archive

- curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).tar.gz + $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).tar.gz
- curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).zip + $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).zip

Encrypt your files before the transfer

You can encrypt files using gpg. The following command will encrypt the data before it leaves your server using the password you enter and upload it to transfer.sh.

- cat /tmp/hello.txt|gpg -ac -o-|curl -X PUT --upload-file "-" https://transfer.sh/test.txt + $ cat /tmp/hello.txt|gpg -ac -o-|curl -X PUT --upload-file "-" https://transfer.sh/test.txt

Encrypt and upload

- curl https://transfer.sh/1lDau/test.txt|gpg -o- > /tmp/hello.txt + $ curl https://transfer.sh/1lDau/test.txt|gpg -o- > /tmp/hello.txt
- diff --git a/transfersh-server/static/scripts/main.js b/transfersh-server/static/scripts/main.js index 44d69b3..1135966 100644 --- a/transfersh-server/static/scripts/main.js +++ b/transfersh-server/static/scripts/main.js @@ -1,3 +1,5 @@ !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b=a.length,c=_.type(a);return"function"===c||_.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}function d(a,b,c){if(_.isFunction(b))return _.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return _.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(hb.test(b))return _.filter(b,a,c);b=_.filter(b,a)}return _.grep(a,function(a){return U.call(b,a)>=0!==c})}function e(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function f(a){var b=ob[a]={};return _.each(a.match(nb)||[],function(a,c){b[c]=!0}),b}function g(){Z.removeEventListener("DOMContentLoaded",g,!1),a.removeEventListener("load",g,!1),_.ready()}function h(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=_.expando+Math.random()}function i(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(ub,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:tb.test(c)?_.parseJSON(c):c}catch(e){}sb.set(a,b,c)}else c=void 0;return c}function j(){return!0}function k(){return!1}function l(){try{return Z.activeElement}catch(a){}}function m(a,b){return _.nodeName(a,"table")&&_.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function n(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function o(a){var b=Kb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function p(a,b){for(var c=0,d=a.length;d>c;c++)rb.set(a[c],"globalEval",!b||rb.get(b[c],"globalEval"))}function q(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(rb.hasData(a)&&(f=rb.access(a),g=rb.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)_.event.add(b,e,j[e][c])}sb.hasData(a)&&(h=sb.access(a),i=_.extend({},h),sb.set(b,i))}}function r(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&_.nodeName(a,b)?_.merge([a],c):c}function s(a,b){var c=b.nodeName.toLowerCase();"input"===c&&yb.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function t(b,c){var d,e=_(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:_.css(e[0],"display");return e.detach(),f}function u(a){var b=Z,c=Ob[a];return c||(c=t(a,b),"none"!==c&&c||(Nb=(Nb||_("