transfer.sh icon indicating copy to clipboard operation
transfer.sh copied to clipboard

[Feature] Read in from stdin/pipe

Open corneliusroemer opened this issue 2 years ago • 4 comments

I'm using the transfer.sh script linked on the website. Would it be possible to extend this script so that I can pipe input into it, rather than having to specify an existing file?

transfer(){ if [ $# -eq 0 ];then echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2;return 1;fi;if tty -s;then file="$1";file_name=$(basename "$file");if [ ! -e "$file" ];then echo "$file: No such file or directory">&2;return 1;fi;if [ -d "$file" ];then file_name="$file_name.zip" ,;(cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null,;else cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;else file_name=$1;curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;}

corneliusroemer avatar Sep 29 '21 17:09 corneliusroemer

@corneliusroemer it's feasible but we still would need a filename for the upload

it could be generated randomly as well, what's your proposed solution for this?

aspacca avatar Sep 29 '21 17:09 aspacca

Random name is perfectly fine in this case, what else should it be :) could of course be passed as a command line argument as extra feature as add on.

corneliusroemer avatar Sep 29 '21 18:09 corneliusroemer

Hi! I've modified the script from the website to accept input from STDIN. Where would you like me to share it? I noticed that there is a separate repository for the web frontend, where the script is currently located

anihm136 avatar Oct 10 '21 14:10 anihm136

@anihm136 you probably want to send a PR for changing https://github.com/dutchcoders/transfer.sh-web/blob/master/src/index.html#L165

aspacca avatar Oct 16 '21 07:10 aspacca