diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2858dda --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Declare files that will always have LF line endings on checkout. +*.sh text eol=lf \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index be14a16..ce7e14d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,9 @@ LABEL maintainer="peez@stiffi.de" RUN apk add --no-cache bash curl COPY / /opt/dropbox_uploader RUN mkdir -p /config && mkdir -p /workdir +RUN apk --no-cache add zip +# for zip file testing +RUN apk --no-cache add p7zip VOLUME /config /workdir diff --git a/Dockerfile.pi b/Dockerfile.pi index cae0d53..8b65414 100644 --- a/Dockerfile.pi +++ b/Dockerfile.pi @@ -4,6 +4,9 @@ MAINTAINER github@vanefferenonline.nl RUN apk update && apk add bash curl COPY *.sh /opt/dropbox_uploader/ RUN mkdir -p /config && mkdir -p /workdir +RUN apk --no-cache add zip +# for zip file testing +RUN apk --no-cache add p7zip VOLUME /config /workdir diff --git a/Dockerfile.pi64 b/Dockerfile.pi64 new file mode 100644 index 0000000..1ed7d77 --- /dev/null +++ b/Dockerfile.pi64 @@ -0,0 +1,15 @@ +FROM arm64v8/alpine:3.13 +MAINTAINER ummar_bhutta@yahoo.com + +RUN apk add --no-cache bash curl +COPY / /opt/dropbox_uploader +RUN mkdir -p /config && mkdir -p /workdir +RUN apk --no-cache add zip +# for zip file testing +RUN apk --no-cache add p7zip + +VOLUME /config /workdir + +WORKDIR /workdir + +ENTRYPOINT ["/opt/dropbox_uploader/dropbox_uploader.sh", "-f", "/config/dropbox_uploader.conf"] diff --git a/README.md b/README.md index 7f59571..25facf5 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,9 @@ Download a file from an URL to a Dropbox folder directly (the file is NOT downlo * **search** <QUERY> Search for a specific pattern on Dropbox and returns the list of matching files or directories +* **meta** <REMOTE_FILE> +Get metadata of provided file. Prints Lastmodfied date/time and size in bytes. Not valid for folders + * **info** Print some info about your Dropbox account @@ -146,6 +149,7 @@ Ignores/excludes directories or files from syncing. ./dropbox_uploader.sh download /backup.zip ./dropbox_uploader.sh delete /backup.zip ./dropbox_uploader.sh mkdir /myDir/ + ./dropbox_uploader.sh meta /path/to/remotefile.zip ./dropbox_uploader.sh upload "My File.txt" "My File 2.txt" ./dropbox_uploader.sh share "My File.txt" ./dropbox_uploader.sh list @@ -158,6 +162,7 @@ Ignores/excludes directories or files from syncing. * MacOSX * Windows/Cygwin * Raspberry Pi +* Raspberry Pi 4 (64-bit Debian OS) * QNAP * iOS * OpenWRT @@ -260,6 +265,9 @@ Using the script with docker makes it also possible to run the script even on wi To use a proxy, just set the mentioned environment variables via the docker `-e` parameter. +### Prebuilt containers +* Rpi4 (ARM/v8) [ARM/V8 Dropbox Uploader on Dockerhub](https://hub.docker.com/layers/ummarbhutta/dropboxuploader/1.1-armv8/images/sha256-16312dea974c08ada6c47156c13b5f09ffb8f2293f787a543269398daa11a396?context=explore) + ## Related projects [thunar-dropbox](https://github.com/mDfRg/Thunar-Dropbox-Uploader-plugin/tree/thunar-dropbox/plugins/thunar): A simple extension to Dropbox Uploader that provides a convenient method to share your Dropbox files with one click! diff --git a/dropbox_uploader.sh b/dropbox_uploader.sh index b9926c2..8c444ef 100755 --- a/dropbox_uploader.sh +++ b/dropbox_uploader.sh @@ -69,7 +69,7 @@ CHUNK_FILE="$TMP_DIR/du_chunk_$RANDOM" TEMP_FILE="$TMP_DIR/du_tmp_$RANDOM" AUTH_ACCESS_TOKEN_EXPIRE="0" BIN_DEPS="sed basename date grep stat dd mkdir" -VERSION="1.0" +VERSION="1.1" umask 077 @@ -275,6 +275,7 @@ function usage echo -e "\t share " echo -e "\t saveurl " echo -e "\t search " + echo -e "\t meta " echo -e "\t info" echo -e "\t space" echo -e "\t unlink" @@ -1013,6 +1014,44 @@ function db_account_space fi } +#Get metadata of file +#$1 Source path (File) +#Returns Lastmodified(DateTime) and Size +function db_getmeta +{ + local SRC=$(normalize_path "$1") + + print "Dropbox Uploader v$VERSION\n\n" + print " > Getting meta data for $SRC\n\n" + + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -X POST -L -s --show-error --globoff -i -o "$RESPONSE_FILE" --header "Authorization: Bearer $OAUTH_ACCESS_TOKEN" --header "Content-Type: application/json" --data "{\"path\": \"$SRC\",\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false}" "$API_METADATA_URL" 2> /dev/null + check_http_response + + #Check + if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then + + type=$(sed -n 's/{".tag": *"*\([^"]*\)"*.*/\1/p' "$RESPONSE_FILE") + + + if [[ $type = "file" ]]; then + + client_modified=$(sed -n 's/.* "server_modified": *"\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}T[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}Z\)".*/\1/p' "$RESPONSE_FILE") + echo -e "LastModified:\t$client_modified" + + size=$(sed -n 's/.*"size": *\([0-9]*\).*/\1/p' "$RESPONSE_FILE") + echo -e "Size:\t$size" + else + print "FAILED: Only files are supported.\n" + ERROR_STATUS=1 + fi + + else + print "FAILED\n" + ERROR_STATUS=1 + fi + +} + #Account unlink function db_unlink { @@ -1813,6 +1852,18 @@ case $COMMAND in ;; + meta) + + if [[ $argnum -lt 1 ]]; then + usage + fi + + FILE_SRC="$ARG1" + + db_getmeta "/$FILE_SRC" + + ;; + *) if [[ $COMMAND != "" ]]; then