init
This commit is contained in:
commit
51d4de07d1
3 changed files with 54 additions and 0 deletions
11
function_tester.sh
Executable file
11
function_tester.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
. ./vivoUpload.fn
|
||||
. ./voeUpload.fn
|
||||
|
||||
|
||||
vivo_url=$( upload_to_vivo "<api_key>" "./BigBuckBunny_512kb.mp4" )
|
||||
voe_url=$( upload_to_voe "<api_key>" "./BigBuckBunny_512kb.mp4" )
|
||||
|
||||
echo -e "Vivo:\t$vivo_url\n"
|
||||
echo -e "Voe:\t$voe_url\n"
|
||||
21
vivoUpload.fn
Executable file
21
vivoUpload.fn
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
function upload_to_vivo () {
|
||||
api_key=$1
|
||||
filepath=$2
|
||||
|
||||
filepath=$( readlink -f "$filepath" )
|
||||
# echo "filepath: $filepath" >&2
|
||||
|
||||
filesize=$(stat -c%s "$filepath")
|
||||
# echo "filesize: $filesize" >&2
|
||||
|
||||
upload_server=$(curl -s -X GET "https://vivo.sx/api/v1/upload/$filesize" -H "Content-Type: application/json" -H "X-AUTH: $api_key")
|
||||
upload_server=$(echo $upload_server | jq ".upload_url")
|
||||
upload_server=${upload_server//\"}
|
||||
# echo "Location: $upload_server" >&2
|
||||
|
||||
vivo_url=$(curl -X POST $upload_server -H "Content-Type: multipart/form-data" -H 'Cache-Control: no-cache' -F action=push -F session=$api_key -F "file=@\"$filepath\"")
|
||||
|
||||
echo "$vivo_url"
|
||||
}
|
||||
22
voeUpload.fn
Executable file
22
voeUpload.fn
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
function upload_to_voe () {
|
||||
api_key=$1
|
||||
filepath=$2
|
||||
|
||||
filepath=$( readlink -f "$filepath" )
|
||||
# echo "filepath: $filepath" >&2
|
||||
|
||||
upload_server=$(curl -s "https://voe.sx/api/upload/server?key=$api_key")
|
||||
upload_server=$(echo $upload_server | jq ".result")
|
||||
upload_server=${upload_server//\"}
|
||||
# echo "Upload Target: $upload_server" >&2
|
||||
|
||||
voe_url=$(curl -X POST $upload_server -H "Content-Type: multipart/form-data" -H 'Cache-Control: no-cache' -F action=push -F api_key=$api_key -F "file=@\"$filepath\"")
|
||||
voe_url=${voe_url#*<textarea name=\"fn\">}
|
||||
voe_url=${voe_url%%</textarea>*}
|
||||
voe_url="https://voe.sx/"${voe_url}
|
||||
# echo "voe_url: $voe_url" >&2
|
||||
|
||||
echo "$voe_url"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue