Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4d87203
Merge pull request #3 from NickHu/master
blha303 May 28, 2013
d3dbe33
MIT License
blha303 May 29, 2013
74ceacb
Add a Bitdeli badge to README
bitdeli-chef Nov 26, 2013
d51c26d
Merge pull request #5 from bitdeli-chef/master
blha303 Nov 26, 2013
d14d256
Update README.md
blha303 Feb 7, 2014
fce7c8b
Delete reference is wrong, fixed
blha303 Mar 8, 2014
448e826
Update apiDocumentation.md
blha303 Mar 8, 2014
0d92f8a
Add note about cURL. closes #7
blha303 Mar 26, 2014
105b715
Small enchaments
raphendyr Mar 26, 2014
26ff5e1
Merge pull request #8 from raphendyr/patch-1
blha303 Mar 26, 2014
dd96c64
/usr/local/bin instead. closes #6
blha303 Mar 26, 2014
fc68f37
Updated, closes #9
blha303 Aug 2, 2014
7e939b0
Added stdin feature
blha303 Oct 15, 2015
ab27bf5
Clean up temp files
blha303 Oct 15, 2015
3c2285f
Fixed issue with bash removing extra spaces
blha303 Oct 15, 2015
ed547f9
Fix bug, silly bash string compare
blha303 Oct 28, 2015
9837ff3
Automatic adding API key to bash profile
blha303 Oct 29, 2015
ef123f4
Don't need to exit after setting the API key
blha303 Nov 5, 2015
a1b0b79
Add fi, fix IPS variable assignment. Closes #12
blha303 Dec 14, 2015
3c443e7
Fixed a few errors in API documentation
obskyr Jan 28, 2016
cdc4d95
Merge pull request #13 from obskyr/master
blha303 Jan 28, 2016
ec12d56
Added key authentication to API documentation
obskyr Jan 29, 2016
b4588aa
Merge pull request #14 from obskyr/master
blha303 Jan 29, 2016
7d8932b
Added information about hash parameter to API doc
obskyr Jan 29, 2016
a56f8ff
Merge pull request #15 from obskyr/master
blha303 Jan 29, 2016
1f0d4f3
Reverted a small part of #13
blha303 Jan 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
19 changes: 19 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ 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
* Copy 'puush' to /usr/bin.
* Use it with `puush file.name`.
* 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`.
* 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`.
41 changes: 24 additions & 17 deletions apiDocumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,47 @@ 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/hist`
- URL: `/api/del`
- Request:
- - k = apikey
- - i = file identifier - on puush.me, is base10 of file hash
- Response (history, success): `{id},{YYYY-MM-DD HH:MM:SS},{url},{filename},{views},{unknown}`
- k = apikey
- i = file identifier - on puush.me, is SEQUENTIAL
- 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}`
- 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 base10 of file hash
- Response (success): image, resized
- Response (failure): `-1`
- k = apikey
- i = file identifier - on puush.me, is SEQUENTIAL
- Response (success): image, 100x100 png
- Response (failure): nothing

###Upload
- URL: `/api/up`
- `Content-Disposition` header needs filename
- Request:
- - k = apikey
- - z = "poop"
- - f = file
- k = apikey
- 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}`
- Response (failure): `-1`
- Response (failure, upload): `-1`
- Response (failure, no filename header): `-2`
- Response (failure, hash didn't match): `-3`
40 changes: 33 additions & 7 deletions puush
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
#!/bin/bash

PUUSH_API_KEY=""
if [ "$1" = "-" ]
then
if [ "$2" != "" ]
then
EXT=$2
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"
fi

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" ]
echo "Please enter your API key:"
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)"
exit 2
elif ! [ -f "$FN" -a -r "$FN" ]
then
echo "Specify a file to be uploaded"
exit
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/'
rm /tmp/puush-tmp.* 2>/dev/null