Giter VIP home page Giter VIP logo

cloudsend.sh's Introduction

Tavinus CloudSender2

Bash script that uses curl to send files and folders to a nextcloud / owncloud publicly shared folder.


If you want to support this project, you can do it here โ˜• ๐Ÿบ

paypal-image


The logic is

cloudsend <file/folder/glob> <PublicURL>

The Origins are here, Thanks for everyone that contributed on the original GIST


Also check my cloudmanager app for a full nextcloud/owncloud webdav client.


Shares with passwords

Cloudsend v2 changed the way password parsing works.
Cloudsend 0.x.x used the -p parameter for the Environment password (changed to -e in v2+).
Please use EITHER -e OR -p, but not both. The last to be called will be used.

  • Env Pass > Set the variable CLOUDSEND_PASSWORD='MySecretPass' and use the option -e
  • Param Pass > Send the password as a parameter with -p <password>

Input Globbing

You can use input globbing (wildcards) by setting the -g option.
This will ignore input file checking and pass the glob to curl to be used.
You MUST NOT rename files when globbing, input file names will be used.
You MUST NOT send folders when globbing, only files are allowed.

Glob examples:

  • '{file1.txt,file2.txt,file3.txt}'
  • 'img[1-100].png'

More info on globbing
https://github.com/tavinus/cloudsend.sh/wiki/Input-Globbing

Read from stdin (pipes)

You can send piped content by using - or . as the input file name (curl specs).
You MUST set a destination file name to use stdin as input ( -r <name> ).

From curl's manual:
Use the file name - (a single dash) to use stdin instead of a given file.
Alternately, the file name . (a single period) may be specified instead of - to use
stdin in non-blocking mode to allow reading server output while stdin is being uploaded.

Sending entire folder

From v2.2.0 cloudsend.sh can send folders. It will traverse the folder tree, create
each folder and send each file. Just use a folder path as input.

image

Other ways to send folders:

This sends every FILE in the current shell folder.

  • change the first ./ to change the input folder ( eg. '/home/myname/myfolder' )
  • -maxdepth 1 will read current folder only, more levels go deeper, supressing goes all levels
find ./ -maxdepth 1 -type f -exec ./cloudsend.sh {} https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG -p yourPassword \;

This sends every FILE inside /home/myname/myfolder, including ALL subfolders.

find /home/myname/myfolder -type f -exec ./cloudsend.sh {} https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG -p yourPassword \;

This sends a gziped tarball of the current shell folder.

tar cf - "$(pwd)" | gzip -9 -c | ./cloudsend.sh - 'https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG' -r myfolder.tar.gz

This sends a gziped tarball of /home/myname/myfolder.

tar cf - /home/myname/myfolder | gzip -9 -c | ./cloudsend.sh - 'https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG' -r myfolder.tar.gz

This sends a recursive zip file of /home/myname/myfolder.

zip -q -r -9 - /home/myname/myfolder | ./cloudsend.sh - 'https://cloud.mydomain.tld/s/TxWdsNX2Ln3X5kxG' -r myfolder.zip

Help info

$./cloudsend.sh --help
Tavinus Cloud Sender v2.2.8

Parameters:
  -h | --help              Print this help and exits
  -q | --quiet             Disables verbose messages
  -V | --version           Prints version and exits
  -r | --rename <file.xxx> Change the destination file name
  -g | --glob              Disable input file checking to use curl globs
  -k | --insecure          Uses curl with -k option (https insecure)
  -l | --limit-rate        Uses curl limit-rate (eg 100k, 1M)
  -a | --abort-on-errors   Aborts on Webdav response errors
  -p | --password <pass>   Uses <pass> as shared folder password
  -e | --envpass           Uses env var $CLOUDSEND_PASSWORD as share password
                           You can 'export CLOUDSEND_PASSWORD' at your system, or set it at the call
                           Please remeber to also call -e to use the password set

Use:
  ./cloudsend.sh [options] <inputPath> <folderLink>
  CLOUDSEND_PASSWORD='MySecretPass' ./cloudsend.sh -e [options] <inputPath> <folderLink>

Passwords:
  Cloudsend 2 changed the way password works
  Cloudsend 0.x.x used the '-p' parameter for the Environment password (changed to -e in v2+)
  Please use EITHER -e OR -p, but not both. The last to be called will be used

    Env Pass > Set the variable CLOUDSEND_PASSWORD='MySecretPass' and use the option '-e'
  Param Pass > Send the password as a parameter with '-p <password>'

Folders:
  Cloudsend 2.2.0 introduces folder tree sending. Just use a directory as <inputPath>.
  It will traverse all files and folders, create the needed folders and send all files.
  Each folder creation and file sending will require a curl call.

Input Globbing:
  You can use input globbing (wildcards) by setting the -g option
  This will ignore input file checking and pass the glob to curl to be used
  You MUST NOT rename files when globbing, input file names will be used
  You MUST NOT send folders when globbing, only files are allowed
  Glob examples: '{file1.txt,file2.txt,file3.txt}'
                 'img[1-100].png'

Send from stdin (pipe):
  You can send piped content by using - or . as the input file name (curl specs)
  You MUST set a destination file name to use stdin as input (-r <name>)

  Use the file name '-' (a single dash) to use stdin instead of a given file
  Alternately, the file name '.' (a single period) may be specified instead of '-' to use
  stdin in non-blocking mode to allow reading server output while stdin is being uploaded

Examples:
  CLOUDSEND_PASSWORD='MySecretPass' ./cloudsend.sh -e './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
  ./cloudsend.sh './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
  ./cloudsend.sh 'my Folder' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
  ./cloudsend.sh -r 'RenamedFile.txt' './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
  ./cloudsend.sh --limit-rate 200K -p 'MySecretPass' './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
  ./cloudsend.sh -p 'MySecretPass' -r 'RenamedFile.txt' './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
  ./cloudsend.sh -g -p 'MySecretPass' '{file1,file2,file3}' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'
  cat file | ./cloudsend.sh - 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28' -r destFileName



Questions

Whats is "https://cloud.mydomain.net/s/fLDzToZF4MLvG28"?
What is a "folderlink"?
Where do i get it from?
Specially the "s/fLDzToZF4MLvG28" part?

You have to share a Folder writable and use the generated link

Shared Folder Screenshot


Troubleshooting

From Nextcloud 21 Documentation
image

cloudsend.sh's People

Contributors

d3473r avatar tavinus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudsend.sh's Issues

Better messages for globbing

Just noticed I need to add better messages for when globbing (currently saying it is gonna send a single file).

I am tired, so I will do it later.

This is to remind me... ๐Ÿ˜

Create folders

Thanks for this great tool!

Following your guide to upload whole folders, I was wondering if it is also possible to preserve the folder tree structure?

It is possible to create folders in the web-interface for a shared link. When a folder is present, one can add it to the url: .../public.php/webdav/folder/bla.txt. But putting folder in there without it being present results in an error:

  <s:message>File with name folder could not be located</s:message>

Is there a way to create folders on the fly?

Cheers,
Sebastian

RPM package for ROSA

Hello!
I have packaged your script into an RPM package, it is now in the contrib repository of ROSA Linux rosa2021.1
https://abf.io/import/cloudsend.sh
It can be installed on ROSA as dnf install cloudsend.sh or dnf install cloudsend.
An RPM can be downloaded from https://abf-downloads.rosalinux.ru/rosa2021.1/repository/x86_64/contrib/release/ and can be installed on other RPM-based distros.
Writing about it just to make you know about it.
Thanks for making this simple, but very useful script! I myself use it for sberdisk.ru (something like a SaaS NextCloud).

Upload to Nextcloud 21 does not work

I am currently trying to upload files to a drop link to Nextcloud version 21.

I am using this example command to upload:
./cloudsend.sh './myfile.txt' 'https://cloud.mydomain.net/s/fLDzToZF4MLvG28'

The upload is done from a alpine 3.13 image with follwing installed:
apk add python3 bash build-base gcc jq coreutils curl

But I am getting this error:


stty: 'standard input': Not a tty
attachments-to-nextcloud    | <html><body><h1>400 Bad request</h1>
attachments-to-nextcloud    | Your browser sent an invalid request.
attachments-to-nextcloud    | </body></html>
attachments-to-nextcloud    | 
attachments-to-nextcloud    | 
attachments-to-nextcloud    |  > Curl exited without errors

Do you have a clue why?

Option to specify the remote file name

Use case: I have a file foo.txt and would like to drop it under the name bar,txt

Potential syntax:

cloudsend foo.txt --remote-file-name bar.txt <folderlink>

Screenshots

To save snapshots and other data.

image

Cheers!
๐Ÿป

return URL after uploading ?

chchang@hqdc039:~/git/cloudsend.sh$ ./cloudsend.sh './cloudsend.sh' 'https://nextcloud.com/index.php/s/somesecrets'
Tavinus Cloud Sender v2.2.5

SENDING SINGLE FILE
===================

cloudsend.sh > 
######################################################################### 100.0%

SUMMARY
=======

 > All Curl calls exited without errors
 > Attempt to send completed > cloudsend.sh

how to return URL after uploading ??

Sending to existing subfolder

Trying to upload to an existing subfolder, I get the following error and the contradictory message that Curl exited without errors.
Omitting the ? and everything after it lets me upload the test file to the root of the shared folder without errors.
Is there already a method to upload to subfolders that I am missing?

> ./cloudsend ~/test.csv "https://cloud.url/s/sometoken?path=%2FPhotos%20%2B%20Videos%2FSubfolder"                                                                                                 Thu Nov 11 14:24:50 2021
Tavinus Cloud Sender v2.2.1


SENDING SINGLE FILE
===================

test.csv > 
######################################################################### 100.0%
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Sabre\DAV\Exception\NotAuthenticated</s:exception>
  <s:message>Username or password was incorrect</s:message>
</d:error>

SUMMARY
=======

 > All Curl calls exited without errors
 > Attempt to send completed > test.csv

Send directories?

Thanks so much for cloudsend! It arrives just on time for my needs :-)

Would it be possible to send (recursively) a directory instead of a single file?
Probably not: I did not even manage to do it from the file-drop web page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.