From 41f4de43ac56b39719e4294cf342874df74edceb Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Sun, 15 Dec 2019 12:42:10 +0530 Subject: [PATCH] Return both URLs after upload Fixes #25 --- assets/templates/html/index.html.tmpl | 9 +++++++-- .../html/newFileUploadPasteSuccess.html.tmpl | 13 +++++++++++++ .../html/newRedirectPasteSuccess.html.tmpl | 13 +++++++++++++ assets/templates/txt/index.txt.tmpl | 9 +++++++-- .../txt/newFileUploadPasteSuccess.txt.tmpl | 11 +++++++---- .../templates/txt/newRedirectPasteSuccess.txt.tmpl | 11 +++++++---- 6 files changed, 54 insertions(+), 12 deletions(-) diff --git a/assets/templates/html/index.html.tmpl b/assets/templates/html/index.html.tmpl index e763a98..f5520f5 100644 --- a/assets/templates/html/index.html.tmpl +++ b/assets/templates/html/index.html.tmpl @@ -14,7 +14,12 @@ the command line. # Shorten a URL curl -F'shorten=http://example.com/some/long/url' https://{{.Request.Host}} - # Shorten a URL with a token to delete it later - curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' https://{{.Request.Host}} + # The first line of the result will contain the shortened URL. + # + # In the other lines, you will find other information, including + # information on how to delete the shortened object. + + # To upload a file and only extract the shortened URL (i.e. throw away the rest) + curl -F'file=@yourfile.png' https://{{.Request.Host}} | head -n 1 {{end}} diff --git a/assets/templates/html/newFileUploadPasteSuccess.html.tmpl b/assets/templates/html/newFileUploadPasteSuccess.html.tmpl index 334f2cb..2879864 100644 --- a/assets/templates/html/newFileUploadPasteSuccess.html.tmpl +++ b/assets/templates/html/newFileUploadPasteSuccess.html.tmpl @@ -1,3 +1,16 @@ {{define "title"}} Success - rushlink +{{end}} + +{{define "body"}} +
+https://{{.Request.Host}}/{{.Paste.Key}}{{.FileExt}}
+---
+
+    # View metadata
+    curl https://{{.Request.Host}}/{{.Paste.Key}}{{.FileExt}}/meta?deleteToken={{.Paste.DeleteToken | urlquery}}
+
+    # Delete this object
+    curl --request DELETE https://{{.Request.Host}}/{{.Paste.Key}}{{.FileExt}}?deleteToken={{.Paste.DeleteToken | urlquery}}
+
{{end}} \ No newline at end of file diff --git a/assets/templates/html/newRedirectPasteSuccess.html.tmpl b/assets/templates/html/newRedirectPasteSuccess.html.tmpl index 334f2cb..2b8f980 100644 --- a/assets/templates/html/newRedirectPasteSuccess.html.tmpl +++ b/assets/templates/html/newRedirectPasteSuccess.html.tmpl @@ -1,3 +1,16 @@ {{define "title"}} Success - rushlink +{{end}} + +{{define "body"}} +
+https://{{.Request.Host}}/{{.Paste.Key}}
+---
+
+# View metadata
+curl https://{{.Request.Host}}/{{.Paste.Key}}/meta?deleteToken={{.Paste.DeleteToken | urlquery}}
+
+# Delete this object
+curl --request DELETE https://{{.Request.Host}}/{{.Paste.Key}}?deleteToken={{.Paste.DeleteToken | urlquery}}
+
{{end}} \ No newline at end of file diff --git a/assets/templates/txt/index.txt.tmpl b/assets/templates/txt/index.txt.tmpl index 7b331b0..5a02660 100644 --- a/assets/templates/txt/index.txt.tmpl +++ b/assets/templates/txt/index.txt.tmpl @@ -12,5 +12,10 @@ the command line. # Shorten a URL curl -F'shorten=http://example.com/some/long/url' https://{{.Request.Host}} - # Shorten a URL with a token to delete it later - curl -F'shorten=http://example.com/some/long/url' -F'deleteToken=' https://{{.Request.Host}} + # The first line of the result will contain the shortened URL. + # + # In the other lines, you will find other information, including + # information on how to delete the shortened object. + + # To upload a file and only extract the shortened URL (i.e. throw away the rest) + curl -F'file=@yourfile.png' https://{{.Request.Host}} | head -n 1 \ No newline at end of file diff --git a/assets/templates/txt/newFileUploadPasteSuccess.txt.tmpl b/assets/templates/txt/newFileUploadPasteSuccess.txt.tmpl index 4b02bbc..7100139 100644 --- a/assets/templates/txt/newFileUploadPasteSuccess.txt.tmpl +++ b/assets/templates/txt/newFileUploadPasteSuccess.txt.tmpl @@ -1,5 +1,8 @@ -{{if .Request.PostForm.deleteToken -}} -https://{{.Request.Host}}/{{.Paste.Key}}{{.FileExt}}?deleteToken={{.Paste.DeleteToken | urlquery}} -{{else -}} https://{{.Request.Host}}/{{.Paste.Key}}{{.FileExt}} -{{end -}} +--- + +# View metadata +curl https://{{.Request.Host}}/{{.Paste.Key}}{{.FileExt}}/meta?deleteToken={{.Paste.DeleteToken | urlquery}} + +# Delete this object +curl --request DELETE https://{{.Request.Host}}/{{.Paste.Key}}{{.FileExt}}?deleteToken={{.Paste.DeleteToken | urlquery}} diff --git a/assets/templates/txt/newRedirectPasteSuccess.txt.tmpl b/assets/templates/txt/newRedirectPasteSuccess.txt.tmpl index dba998e..96ebba8 100644 --- a/assets/templates/txt/newRedirectPasteSuccess.txt.tmpl +++ b/assets/templates/txt/newRedirectPasteSuccess.txt.tmpl @@ -1,5 +1,8 @@ -{{if .Request.PostForm.deleteToken -}} -https://{{.Request.Host}}/{{.Paste.Key}}?deleteToken={{.Paste.DeleteToken | urlquery}} -{{else -}} https://{{.Request.Host}}/{{.Paste.Key}} -{{end -}} +--- + +# View metadata +curl https://{{.Request.Host}}/{{.Paste.Key}}/meta?deleteToken={{.Paste.DeleteToken | urlquery}} + +# Delete this object +curl --request DELETE https://{{.Request.Host}}/{{.Paste.Key}}?deleteToken={{.Paste.DeleteToken | urlquery}}