{"slug": "send-files-to-nextcloud-owncloud-shared-folder-using-curl", "title": "Send files to Nextcloud/Owncloud shared folder using curl", "summary": "This article provides a bash script called `cloudsend.sh` that uses `curl` to upload files to shared folders on Nextcloud or Owncloud. The script accepts a file path and a folder link as arguments, and includes options for quiet mode, insecure HTTPS connections, and password authentication via an environment variable. The project has been migrated to a GitHub repository and will no longer be updated in its original location.", "body_md": "cloudsend.sh\n\n      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.\n      \nLearn more about bidirectional Unicode characters\n\n \n    Show hidden characters\n\n#!/usr/bin/env bash\n\n############################################################\n\n# MIGRATED TO REPOSITORY\n\n# https://github.com/tavinus/cloudsend.sh\n\n#\n\n# This gist will NOT be updated anymore\n\n############################################################\n\n############################################################\n\n#\n\n# cloudsend.sh\n\n#\n\n# Uses curl to send files to a shared\n\n# Nextcloud/Owncloud folder\n\n#\n\n# Usage: ./cloudsend.sh <file> <folderLink>\n\n# Help:  ./cloudsend.sh -h\n\n#\n\n# Gustavo Arnosti Neves\n\n# https://github.com/tavinus\n\n#\n\n# Contributors:\n\n# @MG2R @gessel\n\n#\n\n# Get this script to current folder with:\n\n# curl -O 'https://raw.githubusercontent.com/tavinus/cloudsend.sh/master/cloudsend.sh' && chmod +x cloudsend.sh\n\n#\n\n############################################################\n\nCS_VERSION=\"0.1.6\"\n\nCLOUDURL=\"\"\n\nFOLDERTOKEN=\"\"\n\nPUBSUFFIX=\"public.php/webdav\"\n\nHEADER='X-Requested-With: XMLHttpRequest'\n\nINSECURE=''\n\n# https://cloud.mydomain.net/s/fLDzToZF4MLvG28\n\n# curl -k -T myFile.ext -u \"fLDzToZF4MLvG28:\" -H 'X-Requested-With: XMLHttpRequest' https://cloud.mydomain.net/public.php/webdav/myFile.ext\n\nlog() {\n\n\t[ \"$VERBOSE\" == \" -s\" ] || printf \"%s\\n\" \"$1\"\n\n}\n\nprintVersion() {\n\n        printf \"%s\\n\" \"CloudSender v$CS_VERSION\"\n\n}\n\ninitError() {\n\n        printVersion >&2\n\n        printf \"%s\\n\" \"Init Error! $1\" >&2\n\n        printf \"%s\\n\" \"Try: $0 --help\" >&2\n\n        exit 1\n\n}\n\nusage() {\n\n        printVersion\n\n        printf \"\\n%s%s\\n\" \"Parameters:\" \"\n\n  -h | --help      Print this help and exits\n\n  -q | --quiet     Be quiet\n\n  -V | --version   Prints version and exits\n\n  -k | --insecure  Uses curl with -k option (https insecure)\n\n  -p | --password  Uses env var \\$CLOUDSEND_PASSWORD as share password\n\n                   You can 'export CLOUDSEND_PASSWORD' at your system, or set it at the call.\n\n                   Please remeber to also call -p to use the password set.\"\n\n        printf \"\\n%s\\n%s\\n%s\\n\" \"Use:\" \"  $0 <filepath> <folderLink>\" \"  CLOUDSEND_PASSWORD='MySecretPass' $0 -p <filepath> <folderLink>\"\n\n        printf \"\\n%s\\n%s\\n%s\\n\" \"Example:\" \"  $0 './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'\"  \"   CLOUDSEND_PASSWORD='MySecretPass' $0 -p './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'\"\n\n}\n\n##########################\n\n# Process parameters\n\nif [ \"$1\" = \"-h\" ] || [ \"$1\" = \"--help\" ]; then\n\n        usage\n\n        exit 0\n\nfi\n\nif [ \"$1\" = \"-V\" ] || [ \"$1\" = \"--version\" ]; then\n\n        printVersion\n\n        exit 0\n\nfi\n\nif [ \"$1\" = \"-q\" ] || [ \"$1\" = \"--quiet\" ]; then\n\n        VERBOSE=\" -s\"\n\n\tshift\n\nfi\n\nif [ \"$1\" = \"-k\" ] || [ \"$1\" = \"--insecure\" ]; then\n\n        INSECURE=' -k'\n\n        log \" > Insecure mode ON\"\n\n        shift\n\nfi\n\nif [ \"$1\" = \"-p\" ] || [ \"$1\" = \"--password\" ]; then\n\n        PASSWORD=${CLOUDSEND_PASSWORD}\n\n        log \" > Using password from env\"\n\n        shift\n\nfi\n\n##########################\n\n# Validate input\n\nFILENAME=\"$1\"\n\nCLOUDURL=''\n\n# if we have index.php in the URL, process accordingly\n\nif [[ $2 == *\"index.php\"* ]]; then\n\n        CLOUDURL=\"${2%/index.php/s/*}\"\n\nelse\n\n        CLOUDURL=\"${2%/s/*}\"\n\nfi\n\nFOLDERTOKEN=\"${2##*/s/}\"\n\nif [ ! -f \"$FILENAME\" ]; then\n\n        initError \"Invalid input file: $FILENAME\"\n\nfi\n\nif [ -z \"$CLOUDURL\" ]; then\n\n        initError \"Empty URL! Nowhere to send...\"\n\nfi\n\nif [ -z \"$FOLDERTOKEN\" ]; then\n\n        initError \"Empty Folder Token! Nowhere to send...\"\n\nfi\n\n##########################\n\n# Check for curl\n\nCURLBIN='/usr/bin/curl'\n\nif [ ! -x \"$CURLBIN\" ]; then\n\n        CURLBIN=\"$(which curl 2>/dev/null)\"\n\n        if [ ! -x \"$CURLBIN\" ]; then\n\n                initError \"No curl found on system!\"\n\n        fi\n\nfi\n\n##########################\n\n# Extract base filename\n\nBFILENAME=$(/usr/bin/basename $FILENAME)\n\n##########################\n\n# Send file\n\n#echo \"$CURLBIN\"$INSECURE$VERBOSE -T \"$FILENAME\" -u \"$FOLDERTOKEN\":\"$PASSWORD\" -H \"$HEADER\" \"$CLOUDURL/$PUBSUFFIX/$BFILENAME\"\n\n\"$CURLBIN\"$INSECURE$VERBOSE -T \"$FILENAME\" -u \"$FOLDERTOKEN\":\"$PASSWORD\" -H \"$HEADER\" \"$CLOUDURL/$PUBSUFFIX/$BFILENAME\"", "url": "https://wpnews.pro/news/send-files-to-nextcloud-owncloud-shared-folder-using-curl", "canonical_source": "https://gist.github.com/tavinus/93bdbc051728748787dc22a58dfe58d8", "published_at": "2018-09-24 05:54:38+00:00", "updated_at": "2026-05-22 15:41:46.605887+00:00", "lang": "en", "topics": ["developer-tools", "open-source", "cloud-computing"], "entities": ["Nextcloud", "Owncloud", "curl", "GitHub", "Gustavo Arnosti Neves"], "alternates": {"html": "https://wpnews.pro/news/send-files-to-nextcloud-owncloud-shared-folder-using-curl", "markdown": "https://wpnews.pro/news/send-files-to-nextcloud-owncloud-shared-folder-using-curl.md", "text": "https://wpnews.pro/news/send-files-to-nextcloud-owncloud-shared-folder-using-curl.txt", "jsonld": "https://wpnews.pro/news/send-files-to-nextcloud-owncloud-shared-folder-using-curl.jsonld"}}