implemented preview, fixes small issues to storage, warning on page
unload, etc, etc
This commit is contained in:
@ -68,6 +68,7 @@ func previewHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
contentType, contentLength, err := storage.Head(token, filename)
|
contentType, contentLength, err := storage.Head(token, filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, http.StatusText(404), 404)
|
http.Error(w, http.StatusText(404), 404)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var templatePath string
|
var templatePath string
|
||||||
@ -76,20 +77,29 @@ func previewHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(contentType, "image/"):
|
case strings.HasPrefix(contentType, "image/"):
|
||||||
templatePath = "static/download.image.html"
|
templatePath = "static/download.image.html"
|
||||||
case strings.HasPrefix(contentType, "text/x-markdown"):
|
case strings.HasPrefix(contentType, "text/"):
|
||||||
templatePath = "static/download.md.html"
|
templatePath = "static/download.md.html"
|
||||||
|
|
||||||
var reader io.ReadCloser
|
var reader io.ReadCloser
|
||||||
if reader, _, _, err = storage.Get(token, filename); err != nil {
|
if reader, _, _, err = storage.Get(token, filename); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var data []byte
|
var data []byte
|
||||||
if data, err = ioutil.ReadAll(reader); err != nil {
|
if data, err = ioutil.ReadAll(reader); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(contentType, "text/x-markdown") || strings.HasPrefix(contentType, "text/markdown") {
|
||||||
output := blackfriday.MarkdownCommon(data)
|
output := blackfriday.MarkdownCommon(data)
|
||||||
content = html_template.HTML(output)
|
content = html_template.HTML(output)
|
||||||
case strings.HasPrefix(contentType, "text/"):
|
} else if strings.HasPrefix(contentType, "text/plain") {
|
||||||
|
content = html_template.HTML(fmt.Sprintf("<pre>%s</pre>", data))
|
||||||
|
} else {
|
||||||
|
content = html_template.HTML(data)
|
||||||
|
}
|
||||||
|
|
||||||
templatePath = "static/download.md.html"
|
templatePath = "static/download.md.html"
|
||||||
default:
|
default:
|
||||||
templatePath = "static/download.html"
|
templatePath = "static/download.html"
|
||||||
@ -363,10 +373,17 @@ func zipHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
zw := zip.NewWriter(w)
|
zw := zip.NewWriter(w)
|
||||||
|
|
||||||
for _, key := range strings.Split(files, ",") {
|
for _, key := range strings.Split(files, ",") {
|
||||||
token := sanitize.Path(strings.Split(key, "/")[0])
|
if strings.HasPrefix(key, "/") {
|
||||||
|
key = key[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
key = strings.Replace(key, "\\", "/", -1)
|
||||||
|
|
||||||
|
token := strings.Split(key, "/")[0]
|
||||||
filename := sanitize.Path(strings.Split(key, "/")[1])
|
filename := sanitize.Path(strings.Split(key, "/")[1])
|
||||||
|
|
||||||
reader, _, _, err := storage.Get(token, filename)
|
reader, _, _, err := storage.Get(token, filename)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.Error() == "The specified key does not exist." {
|
if err.Error() == "The specified key does not exist." {
|
||||||
http.Error(w, "File not found", 404)
|
http.Error(w, "File not found", 404)
|
||||||
@ -427,8 +444,14 @@ func tarGzHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
defer zw.Close()
|
defer zw.Close()
|
||||||
|
|
||||||
for _, key := range strings.Split(files, ",") {
|
for _, key := range strings.Split(files, ",") {
|
||||||
|
if strings.HasPrefix(key, "/") {
|
||||||
|
key = key[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
key = strings.Replace(key, "\\", "/", -1)
|
||||||
|
|
||||||
token := strings.Split(key, "/")[0]
|
token := strings.Split(key, "/")[0]
|
||||||
filename := strings.Split(key, "/")[1]
|
filename := sanitize.Path(strings.Split(key, "/")[1])
|
||||||
|
|
||||||
reader, _, contentLength, err := storage.Get(token, filename)
|
reader, _, contentLength, err := storage.Get(token, filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -89,6 +89,8 @@ func main() {
|
|||||||
r.HandleFunc("/download/{token}/{filename}", getHandler).Methods("GET")
|
r.HandleFunc("/download/{token}/{filename}", getHandler).Methods("GET")
|
||||||
|
|
||||||
r.HandleFunc("/{token}/{filename}", previewHandler).MatcherFunc(func(r *http.Request, rm *mux.RouteMatch) bool {
|
r.HandleFunc("/{token}/{filename}", previewHandler).MatcherFunc(func(r *http.Request, rm *mux.RouteMatch) bool {
|
||||||
|
// The file will show a preview page when opening the link in browser directly or
|
||||||
|
// from external link. Otherwise it will download the file immediatly.
|
||||||
if !acceptsHtml(r.Header) {
|
if !acceptsHtml(r.Header) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -98,11 +100,12 @@ func main() {
|
|||||||
u, err := url.Parse(r.Referer())
|
u, err := url.Parse(r.Referer())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
return false
|
return match
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match = match || (u.Host == "transfersh.elasticbeanstalk.com")
|
||||||
|
match = match || (u.Host == "jxm5d6emw5rknovg.onion")
|
||||||
match = match || (u.Host == "transfer.sh")
|
match = match || (u.Host == "transfer.sh")
|
||||||
|
|
||||||
match = match || (u.Host == "127.0.0.1")
|
match = match || (u.Host == "127.0.0.1")
|
||||||
|
|
||||||
return match
|
return match
|
||||||
|
@ -59,6 +59,10 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<h2>
|
<h2>
|
||||||
{{.Filename}}</h2>
|
{{.Filename}}</h2>
|
||||||
|
<h4>
|
||||||
|
Type: <b>{{.ContentType}}</b></h4>
|
||||||
|
<h4>
|
||||||
|
Length: <b>{{.ContentLength}}</b> bytes</h4>
|
||||||
<div>
|
<div>
|
||||||
<a href="#" id="copy-link-btn" class="btn-cta btn">copy link</a>
|
<a href="#" id="copy-link-btn" class="btn-cta btn">copy link</a>
|
||||||
<a href="{{.Url}}" class="btn-cta btn"> download</i> </a>
|
<a href="{{.Url}}" class="btn-cta btn"> download</i> </a>
|
||||||
@ -71,6 +75,54 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<div class="wrapper">
|
||||||
|
<img src="/images/Logo-orange.png" alt="Founded in Holland">
|
||||||
|
<p>Made with <i class="icon-heart"></i> by <a href="http://blog.dutchcoders.io/" title="Dutch Coders">Dutch Coders</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/dutchcoders/transfer.sh/">
|
||||||
|
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var uv = document.createElement('script');
|
||||||
|
uv.type = 'text/javascript';
|
||||||
|
uv.async = true;
|
||||||
|
uv.src = '//widget.uservoice.com/5rkATbLIm8ClJQeOirOhFg.js';
|
||||||
|
var s = document.getElementsByTagName('script')[0];
|
||||||
|
s.parentNode.insertBefore(uv, s)
|
||||||
|
})()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!--[if lt IE 7]>
|
||||||
|
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
|
||||||
|
<![endif]-->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function(b, o, i, l, e, r) {
|
||||||
|
b.GoogleAnalyticsObject = l;
|
||||||
|
b[l] || (b[l] =
|
||||||
|
function() {
|
||||||
|
(b[l].q = b[l].q || []).push(arguments)
|
||||||
|
});
|
||||||
|
b[l].l = +new Date;
|
||||||
|
e = o.createElement(i);
|
||||||
|
r = o.getElementsByTagName(i)[0];
|
||||||
|
e.src = '//www.google-analytics.com/analytics.js';
|
||||||
|
r.parentNode.insertBefore(e, r)
|
||||||
|
}(window, document, 'script', 'ga'));
|
||||||
|
ga('create', 'UA-40833733-1', 'transfer.sh');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="/scripts/main.js"></script>
|
<script src="/scripts/main.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<link rel="stylesheet" href="/styles/main.css">
|
<link rel="stylesheet" href="/styles/main.css">
|
||||||
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
||||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
||||||
<script src="scripts/vendor/modernizr.js"></script>
|
<script src="/scripts/vendor/modernizr.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
@ -66,13 +66,9 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="terminal" class="terminal preview-image">
|
<div id="terminal" class="terminal preview-image">
|
||||||
<img src="http://placehold.it/400x400" alt="">
|
<img src="{{.Url}}" width="400" alt="">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
<div>
|
<div>
|
||||||
@ -88,7 +84,55 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script src="scripts/main.js"></script>
|
<footer>
|
||||||
|
<div class="wrapper">
|
||||||
|
<img src="/images/Logo-orange.png" alt="Founded in Holland">
|
||||||
|
<p>Made with <i class="icon-heart"></i> by <a href="http://blog.dutchcoders.io/" title="Dutch Coders">Dutch Coders</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/dutchcoders/transfer.sh/">
|
||||||
|
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var uv = document.createElement('script');
|
||||||
|
uv.type = 'text/javascript';
|
||||||
|
uv.async = true;
|
||||||
|
uv.src = '//widget.uservoice.com/5rkATbLIm8ClJQeOirOhFg.js';
|
||||||
|
var s = document.getElementsByTagName('script')[0];
|
||||||
|
s.parentNode.insertBefore(uv, s)
|
||||||
|
})()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!--[if lt IE 7]>
|
||||||
|
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
|
||||||
|
<![endif]-->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function(b, o, i, l, e, r) {
|
||||||
|
b.GoogleAnalyticsObject = l;
|
||||||
|
b[l] || (b[l] =
|
||||||
|
function() {
|
||||||
|
(b[l].q = b[l].q || []).push(arguments)
|
||||||
|
});
|
||||||
|
b[l].l = +new Date;
|
||||||
|
e = o.createElement(i);
|
||||||
|
r = o.getElementsByTagName(i)[0];
|
||||||
|
e.src = '//www.google-analytics.com/analytics.js';
|
||||||
|
r.parentNode.insertBefore(e, r)
|
||||||
|
}(window, document, 'script', 'ga'));
|
||||||
|
ga('create', 'UA-40833733-1', 'transfer.sh');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="/scripts/main.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<link rel="stylesheet" href="/styles/main.css">
|
<link rel="stylesheet" href="/styles/main.css">
|
||||||
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
||||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
||||||
<script src="scripts/vendor/modernizr.js"></script>
|
<script src="/scripts/vendor/modernizr.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
@ -55,13 +55,9 @@
|
|||||||
|
|
||||||
<section id="home">
|
<section id="home">
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<h2>
|
<h2>{{.Filename}}</h2>
|
||||||
{{.Filename}}</h2>
|
<h4>Type: <b>{{.ContentType}}</b></h4>
|
||||||
<h4>
|
<h4>Length: <b>{{.ContentLength}}</b> bytes</h4>
|
||||||
Type: <b>{{.ContentType}}</b></h4>
|
|
||||||
<h4>
|
|
||||||
Length: <b>{{.ContentLength}}</b> bytes</h4>
|
|
||||||
<a href="{{.Url}}"></a>
|
|
||||||
<div class="row animated fadeInDown">
|
<div class="row animated fadeInDown">
|
||||||
<div id="from-terminal" class=" box col-md-8 col-md-offset-2 col-xs-12">
|
<div id="from-terminal" class=" box col-md-8 col-md-offset-2 col-xs-12">
|
||||||
<div class="terminal-top">
|
<div class="terminal-top">
|
||||||
@ -117,22 +113,56 @@
|
|||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<footer>
|
||||||
<script src="/scripts/main.js"></script>
|
<div class="wrapper">
|
||||||
|
<img src="/images/Logo-orange.png" alt="Founded in Holland">
|
||||||
|
<p>Made with <i class="icon-heart"></i> by <a href="http://blog.dutchcoders.io/" title="Dutch Coders">Dutch Coders</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/dutchcoders/transfer.sh/">
|
||||||
|
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
|
||||||
|
</a>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
(function() {
|
||||||
var text = $('#md-preview').html();
|
var uv = document.createElement('script');
|
||||||
|
uv.type = 'text/javascript';
|
||||||
var converter = new Showdown.converter();
|
uv.async = true;
|
||||||
var html = converter.makeHtml(text);
|
uv.src = '//widget.uservoice.com/5rkATbLIm8ClJQeOirOhFg.js';
|
||||||
$('#md-preview').empty();
|
var s = document.getElementsByTagName('script')[0];
|
||||||
$('#md-preview').append(html);
|
s.parentNode.insertBefore(uv, s)
|
||||||
|
})()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!--[if lt IE 7]>
|
||||||
|
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
|
||||||
|
<![endif]-->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function(b, o, i, l, e, r) {
|
||||||
|
b.GoogleAnalyticsObject = l;
|
||||||
|
b[l] || (b[l] =
|
||||||
|
function() {
|
||||||
|
(b[l].q = b[l].q || []).push(arguments)
|
||||||
|
});
|
||||||
|
b[l].l = +new Date;
|
||||||
|
e = o.createElement(i);
|
||||||
|
r = o.getElementsByTagName(i)[0];
|
||||||
|
e.src = '//www.google-analytics.com/analytics.js';
|
||||||
|
r.parentNode.insertBefore(e, r)
|
||||||
|
}(window, document, 'script', 'ga'));
|
||||||
|
ga('create', 'UA-40833733-1', 'transfer.sh');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="/scripts/main.js"></script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
@ -8,5 +8,5 @@
|
|||||||
<link rel="stylesheet" href="/styles/main.css">
|
<link rel="stylesheet" href="/styles/main.css">
|
||||||
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
||||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
||||||
<script src="scripts/vendor/modernizr.js"></script>
|
<script src="/scripts/vendor/modernizr.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
<script src="scripts/main.js"></script>
|
<script src="/scripts/main.js"></script>
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<link rel="stylesheet" href="/styles/main.css">
|
<link rel="stylesheet" href="/styles/main.css">
|
||||||
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
||||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
||||||
<script src="scripts/vendor/modernizr.js"></script>
|
<script src="/scripts/vendor/modernizr.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -30,6 +30,7 @@ func (s *LocalStorage) Head(token string, filename string) (contentType string,
|
|||||||
|
|
||||||
var fi os.FileInfo
|
var fi os.FileInfo
|
||||||
if fi, err = os.Lstat(path); err != nil {
|
if fi, err = os.Lstat(path); err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
contentLength = uint64(fi.Size())
|
contentLength = uint64(fi.Size())
|
||||||
@ -49,6 +50,7 @@ func (s *LocalStorage) Get(token string, filename string) (reader io.ReadCloser,
|
|||||||
|
|
||||||
var fi os.FileInfo
|
var fi os.FileInfo
|
||||||
if fi, err = os.Lstat(path); err != nil {
|
if fi, err = os.Lstat(path); err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
contentLength = uint64(fi.Size())
|
contentLength = uint64(fi.Size())
|
||||||
@ -101,8 +103,16 @@ func (s *S3Storage) Head(token string, filename string) (contentType string, con
|
|||||||
|
|
||||||
// content type , content length
|
// content type , content length
|
||||||
response, err := s.bucket.Head(key, map[string][]string{})
|
response, err := s.bucket.Head(key, map[string][]string{})
|
||||||
contentType = ""
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
contentType = response.Header.Get("Content-Type")
|
||||||
|
|
||||||
contentLength, err = strconv.ParseUint(response.Header.Get("Content-Length"), 10, 0)
|
contentLength, err = strconv.ParseUint(response.Header.Get("Content-Length"), 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -112,8 +122,15 @@ func (s *S3Storage) Get(token string, filename string) (reader io.ReadCloser, co
|
|||||||
|
|
||||||
// content type , content length
|
// content type , content length
|
||||||
response, err := s.bucket.GetResponse(key)
|
response, err := s.bucket.GetResponse(key)
|
||||||
contentType = ""
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
contentType = response.Header.Get("Content-Type")
|
||||||
contentLength, err = strconv.ParseUint(response.Header.Get("Content-Length"), 10, 0)
|
contentLength, err = strconv.ParseUint(response.Header.Get("Content-Length"), 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
reader = response.Body
|
reader = response.Body
|
||||||
return
|
return
|
||||||
|
@ -49,6 +49,7 @@ include "includes/head.html"
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
include "includes/footer.html"
|
||||||
include "includes/js.html"
|
include "includes/js.html"
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,13 +40,9 @@ include "includes/head.html"
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="terminal" class="terminal preview-image">
|
<div id="terminal" class="terminal preview-image">
|
||||||
<img src="http://placehold.it/400x400" alt="">
|
<img src="{{.Url}}" width="400" alt="">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
<div>
|
<div>
|
||||||
@ -62,6 +58,7 @@ include "includes/head.html"
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
include "includes/footer.html"
|
||||||
include "includes/js.html"
|
include "includes/js.html"
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -29,19 +29,15 @@ include "includes/head.html"
|
|||||||
|
|
||||||
<section id="home">
|
<section id="home">
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<h2>
|
<h2>{{.Filename}}</h2>
|
||||||
{{.Filename}}</h2>
|
<h4>Type: <b>{{.ContentType}}</b></h4>
|
||||||
<h4>
|
<h4>Length: <b>{{.ContentLength}}</b> bytes</h4>
|
||||||
Type: <b>{{.ContentType}}</b></h4>
|
|
||||||
<h4>
|
|
||||||
Length: <b>{{.ContentLength}}</b> bytes</h4>
|
|
||||||
<a href="{{.Url}}"></a>
|
|
||||||
<div class="row animated fadeInDown">
|
<div class="row animated fadeInDown">
|
||||||
<div id="from-terminal" class=" box col-md-8 col-md-offset-2 col-xs-12">
|
<div id="from-terminal" class=" box col-md-8 col-md-offset-2 col-xs-12">
|
||||||
<div class="terminal-top">
|
<div class="terminal-top">
|
||||||
</div>
|
</div>
|
||||||
<div id="terminal" class="terminal">
|
<div id="terminal" class="terminal">
|
||||||
<div id="md-preview"></div>
|
<div id="md-preview">{{.Content}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -91,20 +87,8 @@ include "includes/head.html"
|
|||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
include "includes/footer.html"
|
||||||
include "includes/js.html"
|
include "includes/js.html"
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
var text = "# Markdown *works*.";
|
|
||||||
|
|
||||||
var converter = new Showdown.converter();
|
|
||||||
var html = converter.makeHtml(text);
|
|
||||||
$('#md-preview').append(html);
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<link rel="stylesheet" href="/styles/main.css">
|
<link rel="stylesheet" href="/styles/main.css">
|
||||||
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:100,200,300' rel='stylesheet' type='text/css'>
|
||||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
<link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
|
||||||
<!-- build:js scripts/vendor/modernizr.js -->
|
<!-- build:js /scripts/vendor/modernizr.js -->
|
||||||
<script src="bower_components/modernizr/modernizr.js"></script>
|
<script src="bower_components/modernizr/modernizr.js"></script>
|
||||||
<!-- endbuild -->
|
<!-- endbuild -->
|
||||||
</head>
|
</head>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- build:js scripts/main.js -->
|
<!-- build:js /scripts/main.js -->
|
||||||
<script src="bower_components/jquery/dist/jquery.js"></script>
|
<script src="bower_components/jquery/dist/jquery.js"></script>
|
||||||
<script src="bower_components/uri.js/src/URI.min.js"></script>
|
<script src="bower_components/uri.js/src/URI.min.js"></script>
|
||||||
<script src="bower_components/bootstrap/js/transition.js"></script>
|
<script src="bower_components/bootstrap/js/transition.js"></script>
|
||||||
|
@ -18,10 +18,18 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var files = Array()
|
var files = Array()
|
||||||
|
var queue = Array()
|
||||||
|
|
||||||
|
$(window).bind('beforeunload', function(){
|
||||||
|
if (queue.length==0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
return 'There are still ' + queue.length + 'files being uploaded.';
|
||||||
|
});
|
||||||
|
|
||||||
function upload(file) {
|
function upload(file) {
|
||||||
|
|
||||||
$('.browse').addClass('uploading');
|
$('.browse').addClass('uploading');
|
||||||
|
|
||||||
var li = $('<li style="clear:both;"/>');
|
var li = $('<li style="clear:both;"/>');
|
||||||
|
|
||||||
li.append($('<div><div class="upload-progress"><span></span><div class="bar" style="width:0%;">####################################################</div></div><p>Uploading... ' + file.name + '</p></div>'));
|
li.append($('<div><div class="upload-progress"><span></span><div class="bar" style="width:0%;">####################################################</div></div><p>Uploading... ' + file.name + '</p></div>'));
|
||||||
@ -34,11 +42,6 @@ $(document).ready(function() {
|
|||||||
$('.upload-progress', $(li)).show();
|
$('.upload-progress', $(li)).show();
|
||||||
$('.upload-progress .bar', $(li)).css('width', pc + "%");
|
$('.upload-progress .bar', $(li)).css('width', pc + "%");
|
||||||
$('.upload-progress span ').empty().append(pc + "%");
|
$('.upload-progress span ').empty().append(pc + "%");
|
||||||
|
|
||||||
|
|
||||||
$(window).bind('beforeunload', function(){
|
|
||||||
return 'File are still uploading';
|
|
||||||
});
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
xhr.onreadystatechange = function(e) {
|
xhr.onreadystatechange = function(e) {
|
||||||
@ -52,8 +55,12 @@ $(document).ready(function() {
|
|||||||
$(li).html('<span>Error (' + xhr.status + ') during upload of file ' + file.name + '</span>');
|
$(li).html('<span>Error (' + xhr.status + ') during upload of file ' + file.name + '</span>');
|
||||||
}
|
}
|
||||||
|
|
||||||
files.push(xhr.responseText.replace("https://transfer.sh/", "").replace("\n", ""));
|
var index = queue.indexOf(xhr);
|
||||||
// files.push(URI(xhr.responseText).absoluteTo(location.href).toString());
|
if (index > -1) {
|
||||||
|
queue.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
files.push(URI(xhr.responseText.replace("\n", "")).path());
|
||||||
|
|
||||||
$(".download-zip").attr("href", URI("(" + files.join(",") + ").zip").absoluteTo(location.href).toString());
|
$(".download-zip").attr("href", URI("(" + files.join(",") + ").zip").absoluteTo(location.href).toString());
|
||||||
$(".download-tar").attr("href", URI("(" + files.join(",") + ").tar.gz").absoluteTo(location.href).toString());
|
$(".download-tar").attr("href", URI("(" + files.join(",") + ").tar.gz").absoluteTo(location.href).toString());
|
||||||
@ -61,7 +68,9 @@ $(document).ready(function() {
|
|||||||
$(".all-files").addClass('show');
|
$(".all-files").addClass('show');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// should queue all uploads.
|
// should queue all uploads.
|
||||||
|
queue.push(xhr);
|
||||||
|
|
||||||
// start upload
|
// start upload
|
||||||
xhr.open("PUT", '/' + file.name, true);
|
xhr.open("PUT", '/' + file.name, true);
|
||||||
@ -84,7 +93,6 @@ $(document).ready(function() {
|
|||||||
var files = event.originalEvent.target.files || event.originalEvent.dataTransfer.files;
|
var files = event.originalEvent.target.files || event.originalEvent.dataTransfer.files;
|
||||||
|
|
||||||
$.each(files, function(index, file) {
|
$.each(files, function(index, file) {
|
||||||
console.debug(file);
|
|
||||||
upload(file);
|
upload(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#download {
|
#download {
|
||||||
//padding-bottom: 200px;
|
|
||||||
footer {
|
footer {
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -6368,7 +6368,6 @@ blockquote.tweet-xl a {
|
|||||||
padding-bottom: 30px;
|
padding-bottom: 30px;
|
||||||
}
|
}
|
||||||
#download footer {
|
#download footer {
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user