droxul 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.coaia/jgwill-droxul.jsonl +6 -0
- package/CHANGELOG.md +224 -221
- package/Dockerfile +11 -11
- package/Dockerfile.pi +12 -12
- package/LICENSE +674 -674
- package/README.md +345 -345
- package/cross-mastery/dropbox-api-get-from-url.js +61 -61
- package/dropbox_uploader.sh +11 -11
- package/help.txt +31 -31
- package/package.json +40 -40
- package/testUnit.sh +0 -0
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
//@cr A File URL is posted to the CHAT in the Resolution Field and the server render the content to the browser with the file content
|
|
2
|
-
|
|
3
|
-
var fetch = require('isomorphic-fetch'); // or another library of choice.
|
|
4
|
-
var fs = require('fs');
|
|
5
|
-
|
|
6
|
-
var path = require('path');
|
|
7
|
-
var Dropbox = require('dropbox').Dropbox;
|
|
8
|
-
var token = process.env.DROPBOX_TOKEN;
|
|
9
|
-
var dbx = new Dropbox({ accessToken: token, fetch: fetch });
|
|
10
|
-
var annoter_file = "9c6a35efe357580f32e759908430643d.annoter.txt";
|
|
11
|
-
var annoter_folder_path = '/x/_/_db/annoter';
|
|
12
|
-
|
|
13
|
-
var target_save_path = path.join(__dirname, annoter_file);
|
|
14
|
-
var annoter_file_path = annoter_folder_path + '/' + annoter_file;
|
|
15
|
-
dbx.filesListFolder({ path: annoter_folder_path })
|
|
16
|
-
.then(function (response) {
|
|
17
|
-
// console.log(response);
|
|
18
|
-
var { entries } = response;
|
|
19
|
-
entries.forEach(file => {
|
|
20
|
-
if (file.name == annoter_file) {
|
|
21
|
-
console.log(file);
|
|
22
|
-
|
|
23
|
-
//@feature Create a Shared Link for the File
|
|
24
|
-
dbx.sharingCreateSharedLink({ path: file.path_lower })
|
|
25
|
-
.then((lnk) => {
|
|
26
|
-
console.log("--------dbx URL---------");
|
|
27
|
-
console.log(lnk.url);
|
|
28
|
-
//@feature Download the file using the URL created
|
|
29
|
-
|
|
30
|
-
dbx.sharingGetSharedLinkFile({ url: lnk.url })
|
|
31
|
-
.then(function (data) {
|
|
32
|
-
console.log("\t-----Downloaded from URL completed------");
|
|
33
|
-
var fname = data.name;
|
|
34
|
-
fs.writeFile(target_save_path, data.fileBinary, 'binary', function (err) {
|
|
35
|
-
if (err) { throw err; }
|
|
36
|
-
console.log('File: ' + target_save_path + ' saved.');
|
|
37
|
-
});
|
|
38
|
-
})
|
|
39
|
-
.catch(function (err) {
|
|
40
|
-
throw err;
|
|
41
|
-
});
|
|
42
|
-
console.log("--------------------");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}).catch((errLNK) => {
|
|
46
|
-
console.log(errLNK);
|
|
47
|
-
})
|
|
48
|
-
;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
.catch(function (error) {
|
|
59
|
-
console.log(error);
|
|
60
|
-
});
|
|
61
|
-
|
|
1
|
+
//@cr A File URL is posted to the CHAT in the Resolution Field and the server render the content to the browser with the file content
|
|
2
|
+
|
|
3
|
+
var fetch = require('isomorphic-fetch'); // or another library of choice.
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var Dropbox = require('dropbox').Dropbox;
|
|
8
|
+
var token = process.env.DROPBOX_TOKEN;
|
|
9
|
+
var dbx = new Dropbox({ accessToken: token, fetch: fetch });
|
|
10
|
+
var annoter_file = "9c6a35efe357580f32e759908430643d.annoter.txt";
|
|
11
|
+
var annoter_folder_path = '/x/_/_db/annoter';
|
|
12
|
+
|
|
13
|
+
var target_save_path = path.join(__dirname, annoter_file);
|
|
14
|
+
var annoter_file_path = annoter_folder_path + '/' + annoter_file;
|
|
15
|
+
dbx.filesListFolder({ path: annoter_folder_path })
|
|
16
|
+
.then(function (response) {
|
|
17
|
+
// console.log(response);
|
|
18
|
+
var { entries } = response;
|
|
19
|
+
entries.forEach(file => {
|
|
20
|
+
if (file.name == annoter_file) {
|
|
21
|
+
console.log(file);
|
|
22
|
+
|
|
23
|
+
//@feature Create a Shared Link for the File
|
|
24
|
+
dbx.sharingCreateSharedLink({ path: file.path_lower })
|
|
25
|
+
.then((lnk) => {
|
|
26
|
+
console.log("--------dbx URL---------");
|
|
27
|
+
console.log(lnk.url);
|
|
28
|
+
//@feature Download the file using the URL created
|
|
29
|
+
|
|
30
|
+
dbx.sharingGetSharedLinkFile({ url: lnk.url })
|
|
31
|
+
.then(function (data) {
|
|
32
|
+
console.log("\t-----Downloaded from URL completed------");
|
|
33
|
+
var fname = data.name;
|
|
34
|
+
fs.writeFile(target_save_path, data.fileBinary, 'binary', function (err) {
|
|
35
|
+
if (err) { throw err; }
|
|
36
|
+
console.log('File: ' + target_save_path + ' saved.');
|
|
37
|
+
});
|
|
38
|
+
})
|
|
39
|
+
.catch(function (err) {
|
|
40
|
+
throw err;
|
|
41
|
+
});
|
|
42
|
+
console.log("--------------------");
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
}).catch((errLNK) => {
|
|
46
|
+
console.log(errLNK);
|
|
47
|
+
})
|
|
48
|
+
;
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
})
|
|
58
|
+
.catch(function (error) {
|
|
59
|
+
console.log(error);
|
|
60
|
+
});
|
|
61
|
+
|
package/dropbox_uploader.sh
CHANGED
|
@@ -342,7 +342,7 @@ function check_http_response
|
|
|
342
342
|
|
|
343
343
|
#Checking response file for generic errors
|
|
344
344
|
if grep -q "^HTTP/[12].* 400" "$RESPONSE_FILE"; then
|
|
345
|
-
ERROR_MSG=$(sed -n -e 's
|
|
345
|
+
ERROR_MSG=$(sed -n -e 's/.*"error": *"\([^"]*\)".*/\1/p' "$RESPONSE_FILE")
|
|
346
346
|
|
|
347
347
|
case $ERROR_MSG in
|
|
348
348
|
*access?attempt?failed?because?this?app?is?not?configured?to?have*)
|
|
@@ -931,16 +931,16 @@ function db_account_info
|
|
|
931
931
|
#Check
|
|
932
932
|
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
|
|
933
933
|
|
|
934
|
-
name=$(sed -n 's/.*"display_name": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
934
|
+
name=$(sed -n 's/.*"display_name": *"\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
935
935
|
echo -e "\n\nName:\t\t$name"
|
|
936
936
|
|
|
937
|
-
uid=$(sed -n 's/.*"account_id": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
937
|
+
uid=$(sed -n 's/.*"account_id": *"\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
938
938
|
echo -e "UID:\t\t$uid"
|
|
939
939
|
|
|
940
|
-
email=$(sed -n 's/.*"email": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
940
|
+
email=$(sed -n 's/.*"email": *"\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
941
941
|
echo -e "Email:\t\t$email"
|
|
942
942
|
|
|
943
|
-
country=$(sed -n 's/.*"country": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
943
|
+
country=$(sed -n 's/.*"country": *"\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
944
944
|
echo -e "Country:\t$country"
|
|
945
945
|
|
|
946
946
|
echo ""
|
|
@@ -962,11 +962,11 @@ function db_account_space
|
|
|
962
962
|
#Check
|
|
963
963
|
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
|
|
964
964
|
|
|
965
|
-
quota=$(sed -n 's/.*"allocated":
|
|
965
|
+
quota=$(sed -n 's/.*"allocated": *\([0-9]*\).*/\1/p' "$RESPONSE_FILE")
|
|
966
966
|
let quota_mb=$quota/1024/1024
|
|
967
967
|
echo -e "\n\nQuota:\t$quota_mb Mb"
|
|
968
968
|
|
|
969
|
-
used=$(sed -n 's/.*"used":
|
|
969
|
+
used=$(sed -n 's/.*"used": *\([0-9]*\).*/\1/p' "$RESPONSE_FILE")
|
|
970
970
|
let used_mb=$used/1024/1024
|
|
971
971
|
echo -e "Used:\t$used_mb Mb"
|
|
972
972
|
|
|
@@ -1126,7 +1126,7 @@ function db_list_outfile
|
|
|
1126
1126
|
#Extracting directory content [...]
|
|
1127
1127
|
#and replacing "}, {" with "}\n{"
|
|
1128
1128
|
#I don't like this piece of code... but seems to be the only way to do this with SED, writing a portable code...
|
|
1129
|
-
local DIR_CONTENT=$(sed -n 's/.*:
|
|
1129
|
+
local DIR_CONTENT=$(sed -n 's/.*:[ ]*\[{\(.*\)/\1/p' "$RESPONSE_FILE" | sed 's/}, *{/}\
|
|
1130
1130
|
{/g')
|
|
1131
1131
|
|
|
1132
1132
|
#Converting escaped quotes to unicode format
|
|
@@ -1335,7 +1335,7 @@ function db_share
|
|
|
1335
1335
|
#Check
|
|
1336
1336
|
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
|
|
1337
1337
|
print " > Share link: "
|
|
1338
|
-
SHARE_LINK=$(sed -n 's/.*"url": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
1338
|
+
SHARE_LINK=$(sed -n 's/.*"url": *"\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
1339
1339
|
echo "$SHARE_LINK"
|
|
1340
1340
|
else
|
|
1341
1341
|
get_Share "$FILE_DST"
|
|
@@ -1353,7 +1353,7 @@ function get_Share
|
|
|
1353
1353
|
#Check
|
|
1354
1354
|
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
|
|
1355
1355
|
print " > Share link: "
|
|
1356
|
-
SHARE_LINK=$(sed -n 's/.*"url": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
1356
|
+
SHARE_LINK=$(sed -n 's/.*"url": *"\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
1357
1357
|
echo "$SHARE_LINK"
|
|
1358
1358
|
else
|
|
1359
1359
|
print "FAILED\n"
|
|
@@ -1470,7 +1470,7 @@ function db_sha
|
|
|
1470
1470
|
return
|
|
1471
1471
|
fi
|
|
1472
1472
|
|
|
1473
|
-
local SHA256=$(sed -n 's/.*"content_hash": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
1473
|
+
local SHA256=$(sed -n 's/.*"content_hash": *"\([^"]*\).*/\1/p' "$RESPONSE_FILE")
|
|
1474
1474
|
echo "$SHA256"
|
|
1475
1475
|
}
|
|
1476
1476
|
|
package/help.txt
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
Dropbox Uploader v1.0
|
|
2
|
-
Andrea Fabrizi - andrea.fabrizi@gmail.com
|
|
3
|
-
|
|
4
|
-
Usage: /home/jgi/x/Dropbox-Uploader/dropbox_uploader.sh [PARAMETERS] COMMAND...
|
|
5
|
-
|
|
6
|
-
Commands:
|
|
7
|
-
upload <LOCAL_FILE/DIR ...> <REMOTE_FILE/DIR>
|
|
8
|
-
download <REMOTE_FILE/DIR> [LOCAL_FILE/DIR]
|
|
9
|
-
delete <REMOTE_FILE/DIR>
|
|
10
|
-
move <REMOTE_FILE/DIR> <REMOTE_FILE/DIR>
|
|
11
|
-
copy <REMOTE_FILE/DIR> <REMOTE_FILE/DIR>
|
|
12
|
-
mkdir <REMOTE_DIR>
|
|
13
|
-
list [REMOTE_DIR]
|
|
14
|
-
monitor [REMOTE_DIR] [TIMEOUT]
|
|
15
|
-
share <REMOTE_FILE>
|
|
16
|
-
saveurl <URL> <REMOTE_DIR>
|
|
17
|
-
search <QUERY>
|
|
18
|
-
info
|
|
19
|
-
space
|
|
20
|
-
unlink
|
|
21
|
-
|
|
22
|
-
Optional parameters:
|
|
23
|
-
-f <FILENAME> Load the configuration file from a specific file
|
|
24
|
-
-s Skip already existing files when download/upload. Default: Overwrite
|
|
25
|
-
-d Enable DEBUG mode
|
|
26
|
-
-q Quiet mode. Don't show messages
|
|
27
|
-
-h Show file sizes in human readable format
|
|
28
|
-
-p Show cURL progress meter
|
|
29
|
-
-k Doesn't check for SSL certificates (insecure)
|
|
30
|
-
-x Ignores/excludes directories or files from syncing. -x filename -x directoryname. example: -x .git
|
|
31
|
-
|
|
1
|
+
Dropbox Uploader v1.0
|
|
2
|
+
Andrea Fabrizi - andrea.fabrizi@gmail.com
|
|
3
|
+
|
|
4
|
+
Usage: /home/jgi/x/Dropbox-Uploader/dropbox_uploader.sh [PARAMETERS] COMMAND...
|
|
5
|
+
|
|
6
|
+
Commands:
|
|
7
|
+
upload <LOCAL_FILE/DIR ...> <REMOTE_FILE/DIR>
|
|
8
|
+
download <REMOTE_FILE/DIR> [LOCAL_FILE/DIR]
|
|
9
|
+
delete <REMOTE_FILE/DIR>
|
|
10
|
+
move <REMOTE_FILE/DIR> <REMOTE_FILE/DIR>
|
|
11
|
+
copy <REMOTE_FILE/DIR> <REMOTE_FILE/DIR>
|
|
12
|
+
mkdir <REMOTE_DIR>
|
|
13
|
+
list [REMOTE_DIR]
|
|
14
|
+
monitor [REMOTE_DIR] [TIMEOUT]
|
|
15
|
+
share <REMOTE_FILE>
|
|
16
|
+
saveurl <URL> <REMOTE_DIR>
|
|
17
|
+
search <QUERY>
|
|
18
|
+
info
|
|
19
|
+
space
|
|
20
|
+
unlink
|
|
21
|
+
|
|
22
|
+
Optional parameters:
|
|
23
|
+
-f <FILENAME> Load the configuration file from a specific file
|
|
24
|
+
-s Skip already existing files when download/upload. Default: Overwrite
|
|
25
|
+
-d Enable DEBUG mode
|
|
26
|
+
-q Quiet mode. Don't show messages
|
|
27
|
+
-h Show file sizes in human readable format
|
|
28
|
+
-p Show cURL progress meter
|
|
29
|
+
-k Doesn't check for SSL certificates (insecure)
|
|
30
|
+
-x Ignores/excludes directories or files from syncing. -x filename -x directoryname. example: -x .git
|
|
31
|
+
|
|
32
32
|
For more info and examples, please see the README file.
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "droxul",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Droxul -- Dropbox Uploader is a **BASH** script which can be used to upload, download, delete, list files (and more!) from **Dropbox**, an online file sharing, synchronization and backup service.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"dk:build": "docker build -t droxul .",
|
|
9
|
-
"dk:build:test": "docker build -t droxul-test tests/",
|
|
10
|
-
"dk:run-fg": "docker run -it -v ${PWD}:/usr/src/app -v /usr/src/app/node_modules -p 4200:4200 --rm droxul",
|
|
11
|
-
"dk:run-fg:test": "docker run -it -v ${PWD}:/usr/src/app -v /usr/src/app/node_modules -p 9876:9876 --rm droxul-test",
|
|
12
|
-
"dk:run-bg": "yarn dk:stop;docker run -d -v ${PWD}:/usr/src/app -v /usr/src/app/node_modules -p 4200:4200 --name droxul-container droxul",
|
|
13
|
-
"dk:run": "npm run dk:run-bg",
|
|
14
|
-
"dk:stop": "docker stop droxul-container;docker rm droxul-container"
|
|
15
|
-
},
|
|
16
|
-
"bin": {
|
|
17
|
-
"droxul": "dropbox_uploader.sh",
|
|
18
|
-
"drox": "dropbox_uploader.sh",
|
|
19
|
-
"dros": "dropShell.sh"
|
|
20
|
-
},
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git@github.com:guillaumeisabelleevaluating/Dropbox-Uploader.git"
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"dropbox",
|
|
27
|
-
"filesystem"
|
|
28
|
-
],
|
|
29
|
-
"author": "andreafabrizi",
|
|
30
|
-
"license": "GNU",
|
|
31
|
-
"publisher": "Guillaume Descoteaux-Isabelle",
|
|
32
|
-
"bugs": {
|
|
33
|
-
"url": "https://github.com/guillaumeisabelleevaluating/Dropbox-Uploader/issues"
|
|
34
|
-
},
|
|
35
|
-
"homepage": "https://github.com/guillaumeisabelleevaluating/Dropbox-Uploader#readme",
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"dropbox": "^4.0.17",
|
|
38
|
-
"isomorphic-fetch": "^2.2.1"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "droxul",
|
|
3
|
+
"version": "1.0.16",
|
|
4
|
+
"description": "Droxul -- Dropbox Uploader is a **BASH** script which can be used to upload, download, delete, list files (and more!) from **Dropbox**, an online file sharing, synchronization and backup service.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"dk:build": "docker build -t droxul .",
|
|
9
|
+
"dk:build:test": "docker build -t droxul-test tests/",
|
|
10
|
+
"dk:run-fg": "docker run -it -v ${PWD}:/usr/src/app -v /usr/src/app/node_modules -p 4200:4200 --rm droxul",
|
|
11
|
+
"dk:run-fg:test": "docker run -it -v ${PWD}:/usr/src/app -v /usr/src/app/node_modules -p 9876:9876 --rm droxul-test",
|
|
12
|
+
"dk:run-bg": "yarn dk:stop;docker run -d -v ${PWD}:/usr/src/app -v /usr/src/app/node_modules -p 4200:4200 --name droxul-container droxul",
|
|
13
|
+
"dk:run": "npm run dk:run-bg",
|
|
14
|
+
"dk:stop": "docker stop droxul-container;docker rm droxul-container"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"droxul": "dropbox_uploader.sh",
|
|
18
|
+
"drox": "dropbox_uploader.sh",
|
|
19
|
+
"dros": "dropShell.sh"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git@github.com:guillaumeisabelleevaluating/Dropbox-Uploader.git"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"dropbox",
|
|
27
|
+
"filesystem"
|
|
28
|
+
],
|
|
29
|
+
"author": "andreafabrizi",
|
|
30
|
+
"license": "GNU",
|
|
31
|
+
"publisher": "Guillaume Descoteaux-Isabelle",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/guillaumeisabelleevaluating/Dropbox-Uploader/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/guillaumeisabelleevaluating/Dropbox-Uploader#readme",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"dropbox": "^4.0.17",
|
|
38
|
+
"isomorphic-fetch": "^2.2.1"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/testUnit.sh
CHANGED
|
File without changes
|