From d3dbe33c0bcba78fa27bcadc1706a2dc6fa758de Mon Sep 17 00:00:00 2001 From: blha303 Date: Wed, 29 May 2013 10:42:22 +0800 Subject: [PATCH 01/20] MIT License --- LICENSE.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..bf82a70 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,19 @@ +Copyright (c) 2013 The puush-linux Team + +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. From 74ceacbf325d26d2d6dc025a1c349561a85a698b Mon Sep 17 00:00:00 2001 From: Bitdeli Chef Date: Tue, 26 Nov 2013 06:14:13 +0000 Subject: [PATCH 02/20] Add a Bitdeli badge to README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4f38781..b9fa25f 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,7 @@ Using * Use it with `puush file.name`. You'll need to set up an environment variable, PUUSH_API_KEY. You can do this per-session with `export PUUSH_API_KEY="apiKeyHere"`, or by putting that command in `~/.bashrc`. + + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/blha303/puush-linux/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + From d14d25666e9bb364aea75bdab0171d752d958e6e Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Fri, 7 Feb 2014 20:30:41 +0800 Subject: [PATCH 03/20] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b9fa25f..28496d7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A Bash script for uploading files to puush.me from Linux. Many thanks to @Westie Using ----- -* Get puush from here: http://b3.blha303.com.au/puush-linux/files/puush +* Get puush from here: https://github.com/blha303/puush-linux/raw/master/puush * Copy 'puush' to /usr/bin. * Use it with `puush file.name`. From fce7c8b824eef58776c424e3681d21baa8dff51c Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Sat, 8 Mar 2014 09:03:00 +0800 Subject: [PATCH 04/20] Delete reference is wrong, fixed --- apiDocumentation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apiDocumentation.md b/apiDocumentation.md index e789dfe..e984064 100644 --- a/apiDocumentation.md +++ b/apiDocumentation.md @@ -10,10 +10,10 @@ puush API documentation - Response (failure): `-1` ###Deletion - - URL: `/api/hist` + - URL: `/api/del` - Request: - - k = apikey - - - i = file identifier - on puush.me, is base10 of file hash + - - i = file identifier - on puush.me, is SEQUENTIAL - Response (history, success): `{id},{YYYY-MM-DD HH:MM:SS},{url},{filename},{views},{unknown}` - Response (failure): `-1` @@ -28,7 +28,7 @@ puush API documentation - URL: `/api/thumb` - Request: - - k = apikey - - - i = file identifier - on puush.me, is base10 of file hash + - - i = file identifier - on puush.me, is SEQUENTIAL - Response (success): image, resized - Response (failure): `-1` From 448e826e36da64ab27137fee8a646cc27dcc0ab5 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Sat, 8 Mar 2014 09:03:41 +0800 Subject: [PATCH 05/20] Update apiDocumentation.md --- apiDocumentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiDocumentation.md b/apiDocumentation.md index e984064..69292b2 100644 --- a/apiDocumentation.md +++ b/apiDocumentation.md @@ -29,7 +29,7 @@ puush API documentation - Request: - - k = apikey - - i = file identifier - on puush.me, is SEQUENTIAL - - Response (success): image, resized + - Response (success): image, 100x100 png - Response (failure): `-1` ###Upload From 0d92f8a5667b7c35731066f2feedff82bb9a58c4 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Thu, 27 Mar 2014 01:55:34 +0800 Subject: [PATCH 06/20] Add note about cURL. closes #7 --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 28496d7..f3614b1 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,9 @@ A Bash script for uploading files to puush.me from Linux. Many thanks to @Westie Using ----- +* Get curl if you don't have it already. Most package managers have it as `curl` (apt-get install curl, yum install curl), or check this page: http://curl.haxx.se/download.html * Get puush from here: https://github.com/blha303/puush-linux/raw/master/puush * Copy 'puush' to /usr/bin. * Use it with `puush file.name`. You'll need to set up an environment variable, PUUSH_API_KEY. You can do this per-session with `export PUUSH_API_KEY="apiKeyHere"`, or by putting that command in `~/.bashrc`. - - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/blha303/puush-linux/trend.png)](https://bitdeli.com/free "Bitdeli Badge") - From 105b715540f890cd114f371fdc1e4379cd27e788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kantoj=C3=A4rvi?= Date: Wed, 26 Mar 2014 20:03:18 +0200 Subject: [PATCH 07/20] Small enchaments --- puush | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/puush b/puush index 232f95a..2ef3918 100755 --- a/puush +++ b/puush @@ -1,15 +1,20 @@ -#!/bin/bash +#!/bin/sh -PUUSH_API_KEY="" +# Uncommend following line if you would like to add api key in this file +#PUUSH_API_KEY="apikeyhere" if [ -z "$PUUSH_API_KEY" ] then echo "Set the variable PUUSH_API_KEY in $0 or with 'export PUUSH_API_KEY=\"apiKeyHere\"" - exit -elif ! [ -r "$1" ] + exit 1 +elif [ -z "$1" ] then echo "Specify a file to be uploaded" - exit + exit 2 +elif ! [ -f "$1" -a -r "$1" ] +then + echo "File '$1' is not valid (it is not a file or it is not readable)" + exit 3 fi curl "https://puush.me/api/up" -# -F "k=$PUUSH_API_KEY" -F "z=poop" -F "f=@$1" | sed -E 's/^.+,(.+),.+,.+$/\1\n/' From dd96c645837443cfa1e6de614c9c8764c49c3139 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Thu, 27 Mar 2014 02:11:04 +0800 Subject: [PATCH 08/20] /usr/local/bin instead. closes #6 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f3614b1..1626d9f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Using * Get curl if you don't have it already. Most package managers have it as `curl` (apt-get install curl, yum install curl), or check this page: http://curl.haxx.se/download.html * Get puush from here: https://github.com/blha303/puush-linux/raw/master/puush -* Copy 'puush' to /usr/bin. +* Copy 'puush' to /usr/local/bin, and use `chmod +x /usr/local/bin/puush`. * Use it with `puush file.name`. You'll need to set up an environment variable, PUUSH_API_KEY. You can do this per-session with `export PUUSH_API_KEY="apiKeyHere"`, or by putting that command in `~/.bashrc`. From fc68f37d09edc6e35025c2eed6a3a9374f2f247a Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Sat, 2 Aug 2014 15:55:01 +0800 Subject: [PATCH 09/20] Updated, closes #9 I haven't checked if the info is accurate, but it can't hurt to send a filename with upload requests. --- apiDocumentation.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apiDocumentation.md b/apiDocumentation.md index 69292b2..4eea34a 100644 --- a/apiDocumentation.md +++ b/apiDocumentation.md @@ -34,9 +34,11 @@ puush API documentation ###Upload - URL: `/api/up` + - `Content-Disposition` header needs filename - Request: - - k = apikey - - z = "poop" - - f = file - Response (upload, success): `0,{url},{id},{size}` - - Response (failure): `-1` + - Response (failure, upload): `-1` + - Response (failure, no filename header): `-2` From 7e939b00830f14e15624acd9f9431ce35c96c141 Mon Sep 17 00:00:00 2001 From: blha303 Date: Fri, 16 Oct 2015 00:20:53 +0800 Subject: [PATCH 10/20] Added stdin feature --- .gitignore | 1 + README.md | 5 +++-- puush | 36 ++++++++++++++++++++++++++---------- 3 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/README.md b/README.md index 1626d9f..83ff185 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Using * Get curl if you don't have it already. Most package managers have it as `curl` (apt-get install curl, yum install curl), or check this page: http://curl.haxx.se/download.html * Get puush from here: https://github.com/blha303/puush-linux/raw/master/puush * Copy 'puush' to /usr/local/bin, and use `chmod +x /usr/local/bin/puush`. -* Use it with `puush file.name`. +* For uploading a file, use `puush file.ext`. +* For uploading from stdin, use `cat file.ext | puush - ext`. -You'll need to set up an environment variable, PUUSH_API_KEY. You can do this per-session with `export PUUSH_API_KEY="apiKeyHere"`, or by putting that command in `~/.bashrc`. +You'll need to set up an environment variable, PUUSH_API_KEY. You can get this key from your puush client in Settings, or from [puush.me](http://puush.me/account/settings). You can set the environment variable per-session with `export PUUSH_API_KEY="apiKeyHere"`, or by putting that command in `~/.bashrc`. diff --git a/puush b/puush index 2ef3918..e64a183 100755 --- a/puush +++ b/puush @@ -1,20 +1,36 @@ #!/bin/sh -# Uncommend following line if you would like to add api key in this file #PUUSH_API_KEY="apikeyhere" +if [ "$1" == "-" ] +then + if [ "$2" != "" ] + then + EXT=$2 + else + EXT="txt" + fi + while read p + do + echo $p >> /tmp/puush-tmp.$EXT + done + FN="/tmp/puush-tmp.$EXT" +else + FN="$1" +fi + if [ -z "$PUUSH_API_KEY" ] then - echo "Set the variable PUUSH_API_KEY in $0 or with 'export PUUSH_API_KEY=\"apiKeyHere\"" - exit 1 -elif [ -z "$1" ] + echo "Set the variable PUUSH_API_KEY in $0 or with 'export PUUSH_API_KEY=\"apiKeyHere\"" + exit 1 +elif [ -z "$FN" ] then - echo "Specify a file to be uploaded" - exit 2 -elif ! [ -f "$1" -a -r "$1" ] + echo "Specify a file to be uploaded" + exit 2 +elif ! [ -f "$FN" -a -r "$FN" ] then - echo "File '$1' is not valid (it is not a file or it is not readable)" - exit 3 + echo "File '$FN' is not valid (it is not a file or it is not readable)" + exit 3 fi -curl "https://puush.me/api/up" -# -F "k=$PUUSH_API_KEY" -F "z=poop" -F "f=@$1" | sed -E 's/^.+,(.+),.+,.+$/\1\n/' +curl "https://puush.me/api/up" -# -F "k=$PUUSH_API_KEY" -F "z=poop" -F "f=@$FN" | sed -E 's/^.+,(.+),.+,.+$/\1\n/' From ab27bf5a4f851c9014d84b828651822006f7fd57 Mon Sep 17 00:00:00 2001 From: blha303 Date: Fri, 16 Oct 2015 00:22:56 +0800 Subject: [PATCH 11/20] Clean up temp files --- puush | 1 + 1 file changed, 1 insertion(+) diff --git a/puush b/puush index e64a183..e28a623 100755 --- a/puush +++ b/puush @@ -34,3 +34,4 @@ then fi curl "https://puush.me/api/up" -# -F "k=$PUUSH_API_KEY" -F "z=poop" -F "f=@$FN" | sed -E 's/^.+,(.+),.+,.+$/\1\n/' +rm /tmp/puush-tmp.* 2>/dev/null From 3c2285fb845a03d5f0eb69282e68fd6ba6f60628 Mon Sep 17 00:00:00 2001 From: blha303 Date: Fri, 16 Oct 2015 00:35:20 +0800 Subject: [PATCH 12/20] Fixed issue with bash removing extra spaces http://s.b303.me/IE2K.html --- puush | 3 +++ 1 file changed, 3 insertions(+) diff --git a/puush b/puush index e28a623..3c7d73f 100755 --- a/puush +++ b/puush @@ -10,10 +10,13 @@ then else EXT="txt" fi + _IFS=$IFS + IFS='' # to preserve spacing while read p do echo $p >> /tmp/puush-tmp.$EXT done + IFS=_IFS FN="/tmp/puush-tmp.$EXT" else FN="$1" From ed547f9bdf2494a7928a41edae11d8ce809c821a Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Wed, 28 Oct 2015 13:22:55 +0800 Subject: [PATCH 13/20] Fix bug, silly bash string compare --- puush | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/puush b/puush index 3c7d73f..ab188e2 100755 --- a/puush +++ b/puush @@ -2,7 +2,7 @@ #PUUSH_API_KEY="apikeyhere" -if [ "$1" == "-" ] +if [ "$1" = "-" ] then if [ "$2" != "" ] then From 9837ff360076880b47171084a1b340f7006ed0d1 Mon Sep 17 00:00:00 2001 From: blha303 Date: Fri, 30 Oct 2015 00:59:55 +0800 Subject: [PATCH 14/20] Automatic adding API key to bash profile --- puush | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/puush b/puush index ab188e2..f002dd1 100755 --- a/puush +++ b/puush @@ -1,6 +1,4 @@ -#!/bin/sh - -#PUUSH_API_KEY="apikeyhere" +#!/bin/bash if [ "$1" = "-" ] then @@ -24,11 +22,14 @@ fi if [ -z "$PUUSH_API_KEY" ] then - echo "Set the variable PUUSH_API_KEY in $0 or with 'export PUUSH_API_KEY=\"apiKeyHere\"" + echo "Please enter your API key:" + read PUUSH_API_KEY + echo "export PUUSH_API_KEY=$PUUSH_API_KEY" >> ~/.bash_profile + echo "Added API key to ~/.bash_profile. Run 'source ~/.bash_profile' to load it, then try again." exit 1 elif [ -z "$FN" ] then - echo "Specify a file to be uploaded" + echo "Specify a file to be uploaded (or use - for stdin)" exit 2 elif ! [ -f "$FN" -a -r "$FN" ] then From ef123f4401904a430ed51474f3762d9735fd905f Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Thu, 5 Nov 2015 18:32:09 +0800 Subject: [PATCH 15/20] Don't need to exit after setting the API key --- puush | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/puush b/puush index f002dd1..0d7493e 100755 --- a/puush +++ b/puush @@ -24,10 +24,9 @@ if [ -z "$PUUSH_API_KEY" ] then echo "Please enter your API key:" read PUUSH_API_KEY - echo "export PUUSH_API_KEY=$PUUSH_API_KEY" >> ~/.bash_profile - echo "Added API key to ~/.bash_profile. Run 'source ~/.bash_profile' to load it, then try again." - exit 1 -elif [ -z "$FN" ] + echo "export PUUSH_API_KEY=$PUUSH_API_KEY" >> ~/.bashrc + echo "Added API key to ~/.bashrc" +if [ -z "$FN" ] then echo "Specify a file to be uploaded (or use - for stdin)" exit 2 From a1b0b79fe4058ea149a79c4ad884a53aa2c0c05f Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Mon, 14 Dec 2015 12:32:51 +0800 Subject: [PATCH 16/20] Add fi, fix IPS variable assignment. Closes #12 --- puush | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/puush b/puush index 0d7493e..685e3ad 100755 --- a/puush +++ b/puush @@ -14,7 +14,7 @@ then do echo $p >> /tmp/puush-tmp.$EXT done - IFS=_IFS + IFS=$_IFS FN="/tmp/puush-tmp.$EXT" else FN="$1" @@ -26,6 +26,7 @@ then read PUUSH_API_KEY echo "export PUUSH_API_KEY=$PUUSH_API_KEY" >> ~/.bashrc echo "Added API key to ~/.bashrc" +fi if [ -z "$FN" ] then echo "Specify a file to be uploaded (or use - for stdin)" From 3c443e7aa70f823625d40d1f8c27386297d29b45 Mon Sep 17 00:00:00 2001 From: obskyr Date: Thu, 28 Jan 2016 15:03:56 +0100 Subject: [PATCH 17/20] Fixed a few errors in API documentation --- apiDocumentation.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apiDocumentation.md b/apiDocumentation.md index 4eea34a..4011270 100644 --- a/apiDocumentation.md +++ b/apiDocumentation.md @@ -14,14 +14,14 @@ puush API documentation - Request: - - k = apikey - - i = file identifier - on puush.me, is SEQUENTIAL - - Response (history, success): `{id},{YYYY-MM-DD HH:MM:SS},{url},{filename},{views},{unknown}` + - Response (success): `0` - Response (failure): `-1` ###History - URL: `/api/hist` - Request: - - k = apikey - - Response (history, success): `{id},{YYYY-MM-DD HH:MM:SS},{url},{filename},{views},{unknown}` + - Response (history, success): up to 10 lines of `{id},{YYYY-MM-DD HH:MM:SS},{url},{filename},{views},{unknown}` - Response (failure): `-1` ###Thumbnail @@ -30,14 +30,14 @@ puush API documentation - - k = apikey - - i = file identifier - on puush.me, is SEQUENTIAL - Response (success): image, 100x100 png - - Response (failure): `-1` + - Response (failure): nothing ###Upload - URL: `/api/up` - `Content-Disposition` header needs filename - Request: - - k = apikey - - - z = "poop" + - - z = anything at all - - f = file - Response (upload, success): `0,{url},{id},{size}` - Response (failure, upload): `-1` From ec12d56b952908e73928bc5b2fc9d7b9d2188ca9 Mon Sep 17 00:00:00 2001 From: obskyr Date: Fri, 29 Jan 2016 02:33:42 +0100 Subject: [PATCH 18/20] Added key authentication to API documentation --- apiDocumentation.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/apiDocumentation.md b/apiDocumentation.md index 4011270..9762c9e 100644 --- a/apiDocumentation.md +++ b/apiDocumentation.md @@ -3,32 +3,35 @@ puush API documentation ###Authentication - URL: `/api/auth` - - Request: - - - e = email address - - - p = password + - Request (two methods, key authentication takes priority): + - With login credentials: + - e = email address + - p = password + - With API key: + - k = apikey - Response (authenticated, success): `{premium},{apikey},[expire],{size-sum}` - Response (failure): `-1` ###Deletion - URL: `/api/del` - Request: - - - k = apikey - - - i = file identifier - on puush.me, is SEQUENTIAL + - k = apikey + - i = file identifier - on puush.me, is SEQUENTIAL - Response (success): `0` - Response (failure): `-1` ###History - URL: `/api/hist` - Request: - - - k = apikey + - k = apikey - Response (history, success): up to 10 lines of `{id},{YYYY-MM-DD HH:MM:SS},{url},{filename},{views},{unknown}` - Response (failure): `-1` ###Thumbnail - URL: `/api/thumb` - Request: - - - k = apikey - - - i = file identifier - on puush.me, is SEQUENTIAL + - k = apikey + - i = file identifier - on puush.me, is SEQUENTIAL - Response (success): image, 100x100 png - Response (failure): nothing @@ -36,9 +39,9 @@ puush API documentation - URL: `/api/up` - `Content-Disposition` header needs filename - Request: - - - k = apikey - - - z = anything at all - - - f = file + - k = apikey + - z = anything at all + - f = file - Response (upload, success): `0,{url},{id},{size}` - Response (failure, upload): `-1` - Response (failure, no filename header): `-2` From 7d8932b6d1a0af94d460881107d89d8c02ec5580 Mon Sep 17 00:00:00 2001 From: obskyr Date: Fri, 29 Jan 2016 13:39:03 +0100 Subject: [PATCH 19/20] Added information about hash parameter to API doc --- apiDocumentation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apiDocumentation.md b/apiDocumentation.md index 9762c9e..531cc58 100644 --- a/apiDocumentation.md +++ b/apiDocumentation.md @@ -42,6 +42,8 @@ puush API documentation - k = apikey - z = anything at all - f = file + - c = MD5 hash of file (optional, will only be used if present in the request) - Response (upload, success): `0,{url},{id},{size}` - Response (failure, upload): `-1` - Response (failure, no filename header): `-2` + - Response (failure, hash didn't match): `-3` From 1f0d4f34a3d8e5c8ebc0c3901fb5bf776756cec0 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Fri, 29 Jan 2016 20:57:56 +0800 Subject: [PATCH 20/20] Reverted a small part of #13 It has to be poop. --- apiDocumentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiDocumentation.md b/apiDocumentation.md index 531cc58..a2d2237 100644 --- a/apiDocumentation.md +++ b/apiDocumentation.md @@ -40,7 +40,7 @@ puush API documentation - `Content-Disposition` header needs filename - Request: - k = apikey - - z = anything at all + - z = "poop" - f = file - c = MD5 hash of file (optional, will only be used if present in the request) - Response (upload, success): `0,{url},{id},{size}`