diff --git a/README.md b/README.md
index 8ba66d1..c1766d7 100755
--- a/README.md
+++ b/README.md
@@ -552,6 +552,20 @@ These are the custom flags that are currently implemented:
---
+- -SM | -sm | --share-mode 'share mode'
+
+ Specify the share mode for sharing file.
+
+ Share modes are:
+
+ - r / reader - Read only permission.
+ - w / writer - Read and write permission.
+ - c / commenter - Comment only permission.
+
+ Note: Although this flag is independent of --share flag but when email is needed, then --share flag use is neccessary.
+
+ ---
+
- --speed 'speed'
Limit the download speed, supported formats: 1K, 1M and 1G.
diff --git a/bash/drive-utils.bash b/bash/drive-utils.bash
index 3ff5afa..c344495 100755
--- a/bash/drive-utils.bash
+++ b/bash/drive-utils.bash
@@ -394,7 +394,7 @@ _full_upload() {
###################################################
_share_id() {
[[ $# -lt 2 ]] && printf "%s: Missing arguments\n" "${FUNCNAME[0]}" && return 1
- declare id="${1}" share_email="${2}" role="reader"
+ declare id="${1}" role="${2:?Missing role}" share_email="${3}"
declare type="${share_email:+user}" share_post_data share_post_data share_response
"${EXTRA_LOG}" "justify" "Sharing.." "-" 1>&2
diff --git a/bash/release/gupload b/bash/release/gupload
index 697e66d..85b47c3 100755
--- a/bash/release/gupload
+++ b/bash/release/gupload
@@ -1318,7 +1318,7 @@ _full_upload() {
###################################################
_share_id() {
[[ $# -lt 2 ]] && printf "%s: Missing arguments\n" "${FUNCNAME[0]}" && return 1
- declare id="${1}" share_email="${2}" role="reader"
+ declare id="${1}" role="${2:?Missing role}" share_email="${3}"
declare type="${share_email:+user}" share_post_data share_post_data share_response
"${EXTRA_LOG}" "justify" "Sharing.." "-" 1>&2
@@ -1554,6 +1554,11 @@ Options:\n
Note: For files inside folders, use --description-all flag.\n
-d | --skip-duplicates - Do not upload the files with the same name, if already present in the root folder/input folder, also works with recursive folders.\n
-S | --share - Share the uploaded input file/folder, grant reader permission to provided email address or to everyone with the shareable link.\n
+ -SM | -sm | --share-mode 'share mode' - Specify the share mode for sharing file.\n
+ Share modes are: r / reader - Read only permission.\n
+ : w / writer - Read and write permission.\n
+ : c / commenter - Comment only permission.\n
+ Note: Although this flag is independent of --share flag but when email is needed, then --share flag use is neccessary.\n
--speed 'speed' - Limit the download speed, supported formats: 1K, 1M and 1G.\n
-i | --save-info - Save uploaded files info to the given filename.\n
-z | --config - Override default config file with custom config file.\nIf you want to change default value, then use this format -z/--config default=default=your_config_file_path.\n
@@ -1646,7 +1651,7 @@ _setup_arguments() {
# De-initialize if any variables set already.
unset LIST_ACCOUNTS UPDATE_DEFAULT_ACCOUNT CUSTOM_ACCOUNT_NAME NEW_ACCOUNT_NAME DELETE_ACCOUNT_NAME ACCOUNT_ONLY_RUN
unset FOLDERNAME LOCAL_INPUT_ARRAY ID_INPUT_ARRAY CONTINUE_WITH_NO_INPUT
- unset PARALLEL NO_OF_PARALLEL_JOBS SHARE SHARE_EMAIL OVERWRITE SKIP_DUPLICATES DESCRIPTION SKIP_SUBDIRS ROOTDIR QUIET
+ unset PARALLEL NO_OF_PARALLEL_JOBS SHARE SHARE_ROLE SHARE_EMAIL OVERWRITE SKIP_DUPLICATES DESCRIPTION SKIP_SUBDIRS ROOTDIR QUIET
unset VERBOSE VERBOSE_PROGRESS DEBUG LOG_FILE_ID CURL_SPEED RETRY
export CURL_PROGRESS="-s" EXTRA_LOG=":" CURL_PROGRESS_EXTRA="-s"
INFO_PATH="${HOME}/.google-drive-upload" CONFIG_INFO="${INFO_PATH}/google-drive-upload.configpath"
@@ -1748,6 +1753,21 @@ _setup_arguments() {
if [[ -n ${2} && ! ${2} = -* && ${2} =~ ${EMAIL_REGEX} ]]; then
SHARE_EMAIL="${2}" && shift && export SHARE_EMAIL
fi
+ SHARE_ROLE="${SHARE_ROLE:-reader}"
+ ;;
+ -[Ss][Mm] | --share-mode)
+ _check_longoptions "${1}" "${2}"
+ case "${2}" in
+ r | read*) SHARE_ROLE="reader" ;;
+ w | write*) SHARE_ROLE="writer" ;;
+ c | comment*) SHARE_ROLE="commenter" ;;
+ *)
+ printf "%s\n" "Invalid share mode given ( ${2} ). Supported values are r or reader / w or writer / c or commenter." &&
+ exit 1
+ ;;
+ esac
+ SHARE="_share_id"
+ shift
;;
--speed)
_check_longoptions "${1}" "${2}"
@@ -1928,7 +1948,7 @@ _setup_workspace() {
# WORKSPACE_FOLDER_ID, UPLOAD_MODE, SKIP_DUPLICATES, OVERWRITE, SHARE,
# UPLOAD_STATUS, COLUMNS, API_URL, API_VERSION, TOKEN_URL, LOG_FILE_ID
# FILE_ID, FILE_LINK, FINAL_ID_INPUT_ARRAY ( array )
-# PARALLEL_UPLOAD, QUIET, NO_OF_PARALLEL_JOBS, TMPFILE
+# PARALLEL_UPLOAD, QUIET, NO_OF_PARALLEL_JOBS, TMPFILE, SHARE_ROLE
# Functions - _print_center, _clear_line, _newline, _support_ansi_escapes, _print_center_quiet
# _upload_file, _share_id, _is_terminal, _dirname,
# _create_directory, _json_value, _url_encode, _check_existing_file, _bytes_to_human
@@ -1939,9 +1959,9 @@ _setup_workspace() {
_process_arguments() {
# on successful uploads
_share_and_print_link() {
- "${SHARE:-:}" "${1:-}" "${SHARE_EMAIL}"
+ "${SHARE:-:}" "${1:-}" "${SHARE_ROLE}" "${SHARE_EMAIL}"
[[ -z ${HIDE_INFO} ]] && {
- _print_center "justify" "DriveLink" "${SHARE:+ (SHARED)}" "-"
+ _print_center "justify" "DriveLink" "${SHARE:+ (SHARED[${SHARE_ROLE:0:1}])}" "-"
_support_ansi_escapes && [[ ${COLUMNS} -gt 45 ]] && _print_center "normal" "↓ ↓ ↓" ' '
"${QUIET:-_print_center}" "normal" "https://drive.google.com/open?id=${1:-}" " "
}
diff --git a/bash/upload.bash b/bash/upload.bash
index dad310d..a8f06bd 100755
--- a/bash/upload.bash
+++ b/bash/upload.bash
@@ -28,6 +28,11 @@ Options:\n
Note: For files inside folders, use --description-all flag.\n
-d | --skip-duplicates - Do not upload the files with the same name, if already present in the root folder/input folder, also works with recursive folders.\n
-S | --share - Share the uploaded input file/folder, grant reader permission to provided email address or to everyone with the shareable link.\n
+ -SM | -sm | --share-mode 'share mode' - Specify the share mode for sharing file.\n
+ Share modes are: r / reader - Read only permission.\n
+ : w / writer - Read and write permission.\n
+ : c / commenter - Comment only permission.\n
+ Note: Although this flag is independent of --share flag but when email is needed, then --share flag use is neccessary.\n
--speed 'speed' - Limit the download speed, supported formats: 1K, 1M and 1G.\n
-i | --save-info - Save uploaded files info to the given filename.\n
-z | --config - Override default config file with custom config file.\nIf you want to change default value, then use this format -z/--config default=default=your_config_file_path.\n
@@ -120,7 +125,7 @@ _setup_arguments() {
# De-initialize if any variables set already.
unset LIST_ACCOUNTS UPDATE_DEFAULT_ACCOUNT CUSTOM_ACCOUNT_NAME NEW_ACCOUNT_NAME DELETE_ACCOUNT_NAME ACCOUNT_ONLY_RUN
unset FOLDERNAME LOCAL_INPUT_ARRAY ID_INPUT_ARRAY CONTINUE_WITH_NO_INPUT
- unset PARALLEL NO_OF_PARALLEL_JOBS SHARE SHARE_EMAIL OVERWRITE SKIP_DUPLICATES DESCRIPTION SKIP_SUBDIRS ROOTDIR QUIET
+ unset PARALLEL NO_OF_PARALLEL_JOBS SHARE SHARE_ROLE SHARE_EMAIL OVERWRITE SKIP_DUPLICATES DESCRIPTION SKIP_SUBDIRS ROOTDIR QUIET
unset VERBOSE VERBOSE_PROGRESS DEBUG LOG_FILE_ID CURL_SPEED RETRY
export CURL_PROGRESS="-s" EXTRA_LOG=":" CURL_PROGRESS_EXTRA="-s"
INFO_PATH="${HOME}/.google-drive-upload" CONFIG_INFO="${INFO_PATH}/google-drive-upload.configpath"
@@ -222,6 +227,21 @@ _setup_arguments() {
if [[ -n ${2} && ! ${2} = -* && ${2} =~ ${EMAIL_REGEX} ]]; then
SHARE_EMAIL="${2}" && shift && export SHARE_EMAIL
fi
+ SHARE_ROLE="${SHARE_ROLE:-reader}"
+ ;;
+ -[Ss][Mm] | --share-mode)
+ _check_longoptions "${1}" "${2}"
+ case "${2}" in
+ r | read*) SHARE_ROLE="reader" ;;
+ w | write*) SHARE_ROLE="writer" ;;
+ c | comment*) SHARE_ROLE="commenter" ;;
+ *)
+ printf "%s\n" "Invalid share mode given ( ${2} ). Supported values are r or reader / w or writer / c or commenter." &&
+ exit 1
+ ;;
+ esac
+ SHARE="_share_id"
+ shift
;;
--speed)
_check_longoptions "${1}" "${2}"
@@ -402,7 +422,7 @@ _setup_workspace() {
# WORKSPACE_FOLDER_ID, UPLOAD_MODE, SKIP_DUPLICATES, OVERWRITE, SHARE,
# UPLOAD_STATUS, COLUMNS, API_URL, API_VERSION, TOKEN_URL, LOG_FILE_ID
# FILE_ID, FILE_LINK, FINAL_ID_INPUT_ARRAY ( array )
-# PARALLEL_UPLOAD, QUIET, NO_OF_PARALLEL_JOBS, TMPFILE
+# PARALLEL_UPLOAD, QUIET, NO_OF_PARALLEL_JOBS, TMPFILE, SHARE_ROLE
# Functions - _print_center, _clear_line, _newline, _support_ansi_escapes, _print_center_quiet
# _upload_file, _share_id, _is_terminal, _dirname,
# _create_directory, _json_value, _url_encode, _check_existing_file, _bytes_to_human
@@ -413,9 +433,9 @@ _setup_workspace() {
_process_arguments() {
# on successful uploads
_share_and_print_link() {
- "${SHARE:-:}" "${1:-}" "${SHARE_EMAIL}"
+ "${SHARE:-:}" "${1:-}" "${SHARE_ROLE}" "${SHARE_EMAIL}"
[[ -z ${HIDE_INFO} ]] && {
- _print_center "justify" "DriveLink" "${SHARE:+ (SHARED)}" "-"
+ _print_center "justify" "DriveLink" "${SHARE:+ (SHARED[${SHARE_ROLE:0:1}])}" "-"
_support_ansi_escapes && [[ ${COLUMNS} -gt 45 ]] && _print_center "normal" "↓ ↓ ↓" ' '
"${QUIET:-_print_center}" "normal" "https://drive.google.com/open?id=${1:-}" " "
}
diff --git a/sh/drive-utils.sh b/sh/drive-utils.sh
index fa10452..10997f8 100755
--- a/sh/drive-utils.sh
+++ b/sh/drive-utils.sh
@@ -398,7 +398,7 @@ _full_upload() {
###################################################
_share_id() {
[ $# -lt 2 ] && printf "Missing arguments\n" && return 1
- id_share_id="${1}" share_email_share_id="${2}" role_share_id="reader" type_share_id="${share_email_share_id:+user}"
+ id_share_id="${1}" role_share_id="${2:?Missing role}" share_email_share_id="${3}" role_share_id="reader" type_share_id="${share_email_share_id:+user}"
unset post_data_share_id response_share_id
"${EXTRA_LOG}" "justify" "Sharing.." "-" 1>&2
diff --git a/sh/release/gupload b/sh/release/gupload
index 9ec3290..102eb0a 100755
--- a/sh/release/gupload
+++ b/sh/release/gupload
@@ -1263,7 +1263,7 @@ _full_upload() {
###################################################
_share_id() {
[ $# -lt 2 ] && printf "Missing arguments\n" && return 1
- id_share_id="${1}" share_email_share_id="${2}" role_share_id="reader" type_share_id="${share_email_share_id:+user}"
+ id_share_id="${1}" role_share_id="${2:?Missing role}" share_email_share_id="${3}" role_share_id="reader" type_share_id="${share_email_share_id:+user}"
unset post_data_share_id response_share_id
"${EXTRA_LOG}" "justify" "Sharing.." "-" 1>&2
@@ -1480,6 +1480,11 @@ Options:\n
Note: For files inside folders, use --description-all flag.\n
-d | --skip-duplicates - Do not upload the files with the same name, if already present in the root folder/input folder, also works with recursive folders.\n
-S | --share - Share the uploaded input file/folder, grant reader permission to provided email address or to everyone with the shareable link.\n
+ -SM | -sm | --share-mode 'share mode' - Specify the share mode for sharing file.\n
+ Share modes are: r / reader - Read only permission.\n
+ : w / writer - Read and write permission.\n
+ : c / commenter - Comment only permission.\n
+ Note: Although this flag is independent of --share flag but when email is needed, then --share flag use is neccessary.\n
--speed 'speed' - Limit the download speed, supported formats: 1K, 1M and 1G.\n
-i | --save-info - Save uploaded files info to the given filename.\n
-z | --config - Override default config file with custom config file.\nIf you want to change default value, then use this format -z/--config default=default=your_config_file_path.\n
@@ -1574,7 +1579,7 @@ _setup_arguments() {
# De-initialize if any variables set already.
unset LIST_ACCOUNTS UPDATE_DEFAULT_ACCOUNT CUSTOM_ACCOUNT_NAME NEW_ACCOUNT_NAME DELETE_ACCOUNT_NAME ACCOUNT_ONLY_RUN
unset FOLDERNAME FINAL_LOCAL_INPUT_ARRAY FINAL_ID_INPUT_ARRAY CONTINUE_WITH_NO_INPUT
- unset PARALLEL NO_OF_PARALLEL_JOBS SHARE SHARE_EMAIL OVERWRITE SKIP_DUPLICATES SKIP_SUBDIRS DESCRIPTION ROOTDIR QUIET
+ unset PARALLEL NO_OF_PARALLEL_JOBS SHARE SHARE_EMAIL SHARE_ROLE OVERWRITE SKIP_DUPLICATES SKIP_SUBDIRS DESCRIPTION ROOTDIR QUIET
unset VERBOSE VERBOSE_PROGRESS DEBUG LOG_FILE_ID CURL_SPEED RETRY
export CURL_PROGRESS="-s" EXTRA_LOG=":" CURL_PROGRESS_EXTRA="-s"
INFO_PATH="${HOME}/.google-drive-upload" CONFIG_INFO="${INFO_PATH}/google-drive-upload.configpath"
@@ -1683,6 +1688,21 @@ _setup_arguments() {
fi
;;
esac
+ SHARE_ROLE="${SHARE_ROLE:-reader}"
+ ;;
+ -[Ss][Mm] | --share-mode)
+ _check_longoptions "${1}" "${2}"
+ case "${2}" in
+ r | read*) SHARE_ROLE="reader" ;;
+ w | write*) SHARE_ROLE="writer" ;;
+ c | comment*) SHARE_ROLE="commenter" ;;
+ *)
+ printf "%s\n" "Invalid share mode given ( ${2} ). Supported values are r or reader / w or writer / c or commenter." &&
+ exit 1
+ ;;
+ esac
+ SHARE="_share_id"
+ shift
;;
--speed)
_check_longoptions "${1}" "${2}"
@@ -1869,7 +1889,7 @@ _setup_workspace() {
# WORKSPACE_FOLDER_ID, UPLOAD_MODE, SKIP_DUPLICATES, OVERWRITE, SHARE,
# UPLOAD_STATUS, COLUMNS, API_URL, API_VERSION, TOKEN_URL, LOG_FILE_ID
# FILE_ID, FILE_LINK, FINAL_ID_INPUT_ARRAY ( array )
-# PARALLEL_UPLOAD, QUIET, NO_OF_PARALLEL_JOBS, TMPFILE
+# PARALLEL_UPLOAD, QUIET, NO_OF_PARALLEL_JOBS, TMPFILE, SHARE_ROLE
# Functions - _print_center, _clear_line, _newline, _support_ansi_escapes, _print_center_quiet
# _upload_file, _share_id, _is_terminal, _dirname,
# _create_directory, _json_value, _url_encode, _check_existing_file, _bytes_to_human
@@ -1881,9 +1901,9 @@ _process_arguments() {
export SOURCE_UTILS
# on successful uploads
_share_and_print_link() {
- "${SHARE:-:}" "${1:-}" "${SHARE_EMAIL}"
+ "${SHARE:-:}" "${1:-}" "${SHARE_ROLE}" "${SHARE_EMAIL}"
[ -z "${HIDE_INFO}" ] && {
- _print_center "justify" "DriveLink" "${SHARE:+ (SHARED)}" "-"
+ _print_center "justify" "DriveLink" "${SHARE:+ (SHARED[$(printf "%.1s" "${SHARE_ROLE}")])}" "-"
_support_ansi_escapes && [ "$((COLUMNS))" -gt 45 ] 2>| /dev/null && _print_center "normal" '^ ^ ^' ' '
"${QUIET:-_print_center}" "normal" "https://drive.google.com/open?id=${1:-}" " "
}
diff --git a/sh/upload.sh b/sh/upload.sh
index 6414a67..50dcc9c 100755
--- a/sh/upload.sh
+++ b/sh/upload.sh
@@ -28,6 +28,11 @@ Options:\n
Note: For files inside folders, use --description-all flag.\n
-d | --skip-duplicates - Do not upload the files with the same name, if already present in the root folder/input folder, also works with recursive folders.\n
-S | --share - Share the uploaded input file/folder, grant reader permission to provided email address or to everyone with the shareable link.\n
+ -SM | -sm | --share-mode 'share mode' - Specify the share mode for sharing file.\n
+ Share modes are: r / reader - Read only permission.\n
+ : w / writer - Read and write permission.\n
+ : c / commenter - Comment only permission.\n
+ Note: Although this flag is independent of --share flag but when email is needed, then --share flag use is neccessary.\n
--speed 'speed' - Limit the download speed, supported formats: 1K, 1M and 1G.\n
-i | --save-info - Save uploaded files info to the given filename.\n
-z | --config - Override default config file with custom config file.\nIf you want to change default value, then use this format -z/--config default=default=your_config_file_path.\n
@@ -122,7 +127,7 @@ _setup_arguments() {
# De-initialize if any variables set already.
unset LIST_ACCOUNTS UPDATE_DEFAULT_ACCOUNT CUSTOM_ACCOUNT_NAME NEW_ACCOUNT_NAME DELETE_ACCOUNT_NAME ACCOUNT_ONLY_RUN
unset FOLDERNAME FINAL_LOCAL_INPUT_ARRAY FINAL_ID_INPUT_ARRAY CONTINUE_WITH_NO_INPUT
- unset PARALLEL NO_OF_PARALLEL_JOBS SHARE SHARE_EMAIL OVERWRITE SKIP_DUPLICATES SKIP_SUBDIRS DESCRIPTION ROOTDIR QUIET
+ unset PARALLEL NO_OF_PARALLEL_JOBS SHARE SHARE_EMAIL SHARE_ROLE OVERWRITE SKIP_DUPLICATES SKIP_SUBDIRS DESCRIPTION ROOTDIR QUIET
unset VERBOSE VERBOSE_PROGRESS DEBUG LOG_FILE_ID CURL_SPEED RETRY
export CURL_PROGRESS="-s" EXTRA_LOG=":" CURL_PROGRESS_EXTRA="-s"
INFO_PATH="${HOME}/.google-drive-upload" CONFIG_INFO="${INFO_PATH}/google-drive-upload.configpath"
@@ -231,6 +236,21 @@ _setup_arguments() {
fi
;;
esac
+ SHARE_ROLE="${SHARE_ROLE:-reader}"
+ ;;
+ -[Ss][Mm] | --share-mode)
+ _check_longoptions "${1}" "${2}"
+ case "${2}" in
+ r | read*) SHARE_ROLE="reader" ;;
+ w | write*) SHARE_ROLE="writer" ;;
+ c | comment*) SHARE_ROLE="commenter" ;;
+ *)
+ printf "%s\n" "Invalid share mode given ( ${2} ). Supported values are r or reader / w or writer / c or commenter." &&
+ exit 1
+ ;;
+ esac
+ SHARE="_share_id"
+ shift
;;
--speed)
_check_longoptions "${1}" "${2}"
@@ -417,7 +437,7 @@ _setup_workspace() {
# WORKSPACE_FOLDER_ID, UPLOAD_MODE, SKIP_DUPLICATES, OVERWRITE, SHARE,
# UPLOAD_STATUS, COLUMNS, API_URL, API_VERSION, TOKEN_URL, LOG_FILE_ID
# FILE_ID, FILE_LINK, FINAL_ID_INPUT_ARRAY ( array )
-# PARALLEL_UPLOAD, QUIET, NO_OF_PARALLEL_JOBS, TMPFILE
+# PARALLEL_UPLOAD, QUIET, NO_OF_PARALLEL_JOBS, TMPFILE, SHARE_ROLE
# Functions - _print_center, _clear_line, _newline, _support_ansi_escapes, _print_center_quiet
# _upload_file, _share_id, _is_terminal, _dirname,
# _create_directory, _json_value, _url_encode, _check_existing_file, _bytes_to_human
@@ -429,9 +449,9 @@ _process_arguments() {
export SOURCE_UTILS
# on successful uploads
_share_and_print_link() {
- "${SHARE:-:}" "${1:-}" "${SHARE_EMAIL}"
+ "${SHARE:-:}" "${1:-}" "${SHARE_ROLE}" "${SHARE_EMAIL}"
[ -z "${HIDE_INFO}" ] && {
- _print_center "justify" "DriveLink" "${SHARE:+ (SHARED)}" "-"
+ _print_center "justify" "DriveLink" "${SHARE:+ (SHARED[$(printf "%.1s" "${SHARE_ROLE}")])}" "-"
_support_ansi_escapes && [ "$((COLUMNS))" -gt 45 ] 2>| /dev/null && _print_center "normal" '^ ^ ^' ' '
"${QUIET:-_print_center}" "normal" "https://drive.google.com/open?id=${1:-}" " "
}