GithubHelp home page GithubHelp logo

dutchcoders / transfer.sh Goto Github PK

View Code? Open in Web Editor NEW
15.0K 212.0 1.5K 34.29 MB

Easy and fast file sharing from the command-line.

Home Page: https://github.com/dutchcoders/transfer.sh

License: MIT License

Shell 6.58% Go 83.30% Dockerfile 1.01% Nix 9.04% Makefile 0.07%
golang transfer docker share transfersh hacktoberfest hacktoberfest2021

transfer.sh's Introduction

transfer.sh Go Report Card Docker pulls Build Status

Easy and fast file sharing from the command-line. This code contains the server with everything you need to create your own instance.

Transfer.sh currently supports the s3 (Amazon S3), gdrive (Google Drive), storj (Storj) providers, and local file system (local).

Disclaimer

The service at transfersh.com is of unknown origin and reported as cloud malware.

Usage

Upload:

$ curl -v --upload-file ./hello.txt https://transfer.sh/hello.txt

Encrypt & Upload:

$ gpg --armor --symmetric --output - /tmp/hello.txt | curl --upload-file - https://transfer.sh/test.txt

Download & Decrypt:

$ curl https://transfer.sh/1lDau/test.txt | gpg --decrypt --output /tmp/hello.txt

Upload to Virustotal:

$ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/virustotal

Deleting

$ curl -X DELETE <X-Url-Delete Response Header URL>

Request Headers

Max-Downloads

$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H "Max-Downloads: 1" # Limit the number of downloads

Max-Days

$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H "Max-Days: 1" # Set the number of days before deletion

X-Encrypt-Password

Beware, use this feature only on your self-hosted server: trusting a third-party service for server side encryption is at your own risk

$ curl --upload-file ./hello.txt https://your-transfersh-instance.tld/hello.txt -H "X-Encrypt-Password: test" # Encrypt the content sever side with AES265 using "test" as password

X-Decrypt-Password

Beware, use this feature only on your self-hosted server: trusting a third-party service for server side encryption is at your own risk

$ curl https://your-transfersh-instance.tld/BAYh0/hello.txt -H "X-Decrypt-Password: test" # Decrypt the content sever side with AES265 using "test" as password

Response Headers

X-Url-Delete

The URL used to request the deletion of a file and returned as a response header.

curl -sD - --upload-file ./hello.txt https://transfer.sh/hello.txt | grep -i -E 'transfer\.sh|x-url-delete'
x-url-delete: https://transfer.sh/hello.txt/BAYh0/hello.txt/PDw0NHPcqU
https://transfer.sh/hello.txt/BAYh0/hello.txt

Examples

See good usage examples on examples.md

Link aliases

Create direct download link:

https://transfer.sh/1lDau/test.txt --> https://transfer.sh/get/1lDau/test.txt

Inline file:

https://transfer.sh/1lDau/test.txt --> https://transfer.sh/inline/1lDau/test.txt

Usage

Parameter Description Value Env
listener port to use for http (:80) LISTENER
profile-listener port to use for profiler (:6060) PROFILE_LISTENER
force-https redirect to https false FORCE_HTTPS
tls-listener port to use for https (:443) TLS_LISTENER
tls-listener-only flag to enable tls listener only TLS_LISTENER_ONLY
tls-cert-file path to tls certificate TLS_CERT_FILE
tls-private-key path to tls private key TLS_PRIVATE_KEY
http-auth-user user for basic http auth on upload HTTP_AUTH_USER
http-auth-pass pass for basic http auth on upload HTTP_AUTH_PASS
http-auth-htpasswd htpasswd file path for basic http auth on upload HTTP_AUTH_HTPASSWD
http-auth-ip-whitelist comma separated list of ips allowed to upload without being challenged an http auth HTTP_AUTH_IP_WHITELIST
ip-whitelist comma separated list of ips allowed to connect to the service IP_WHITELIST
ip-blacklist comma separated list of ips not allowed to connect to the service IP_BLACKLIST
temp-path path to temp folder system temp TEMP_PATH
web-path path to static web files (for development or custom front end) WEB_PATH
proxy-path path prefix when service is run behind a proxy PROXY_PATH
proxy-port port of the proxy when the service is run behind a proxy PROXY_PORT
email-contact email contact for the front end EMAIL_CONTACT
ga-key google analytics key for the front end GA_KEY
provider which storage provider to use (s3, storj, gdrive or local)
uservoice-key user voice key for the front end USERVOICE_KEY
aws-access-key aws access key AWS_ACCESS_KEY
aws-secret-key aws access key AWS_SECRET_KEY
bucket aws bucket BUCKET
s3-endpoint Custom S3 endpoint. S3_ENDPOINT
s3-region region of the s3 bucket eu-west-1 S3_REGION
s3-no-multipart disables s3 multipart upload false S3_NO_MULTIPART
s3-path-style Forces path style URLs, required for Minio. false S3_PATH_STYLE
storj-access Access for the project STORJ_ACCESS
storj-bucket Bucket to use within the project STORJ_BUCKET
basedir path storage for local/gdrive provider BASEDIR
gdrive-client-json-filepath path to oauth client json config for gdrive provider GDRIVE_CLIENT_JSON_FILEPATH
gdrive-local-config-path path to store local transfer.sh config cache for gdrive provider GDRIVE_LOCAL_CONFIG_PATH
gdrive-chunk-size chunk size for gdrive upload in megabytes, must be lower than available memory (8 MB) GDRIVE_CHUNK_SIZE
lets-encrypt-hosts hosts to use for lets encrypt certificates (comma seperated) HOSTS
log path to log file LOG
cors-domains comma separated list of domains for CORS, setting it enable CORS CORS_DOMAINS
clamav-host host for clamav feature CLAMAV_HOST
perform-clamav-prescan prescan every upload through clamav feature (clamav-host must be a local clamd unix socket) PERFORM_CLAMAV_PRESCAN
rate-limit request per minute RATE_LIMIT
max-upload-size max upload size in kilobytes MAX_UPLOAD_SIZE
purge-days number of days after the uploads are purged automatically PURGE_DAYS
purge-interval interval in hours to run the automatic purge for (not applicable to S3 and Storj) PURGE_INTERVAL
random-token-length length of the random token for the upload path (double the size for delete path) 6 RANDOM_TOKEN_LENGTH

If you want to use TLS using lets encrypt certificates, set lets-encrypt-hosts to your domain, set tls-listener to :443 and enable force-https.

If you want to use TLS using your own certificates, set tls-listener to :443, force-https, tls-cert-file and tls-private-key.

Development

Switched to GO111MODULE

go run main.go --provider=local --listener :8080 --temp-path=/tmp/ --basedir=/tmp/

Build

$ git clone [email protected]:dutchcoders/transfer.sh.git
$ cd transfer.sh
$ go build -o transfersh main.go

Docker

For easy deployment, we've created an official Docker container. There are two variants, differing only by which user runs the process.

The default one will run as root:

docker run --publish 8080:8080 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/

The one tagged with the suffix -noroot will use 5000 as both UID and GID:

docker run --publish 8080:8080 dutchcoders/transfer.sh:latest-noroot --provider local --basedir /tmp/

Building the Container

You can also build the container yourself. This allows you to choose which UID/GID will be used, e.g. when using NFS mounts:

# Build arguments:
# * RUNAS: If empty, the container will run as root.
#          Set this to anything to enable UID/GID selection.
# * PUID:  UID of the process. Needs RUNAS != "". Defaults to 5000.
# * PGID:  GID of the process. Needs RUNAS != "". Defaults to 5000.

docker build -t transfer.sh-noroot --build-arg RUNAS=doesntmatter --build-arg PUID=1337 --build-arg PGID=1338 .

S3 Usage

For the usage with a AWS S3 Bucket, you just need to specify the following options:

  • provider --provider s3
  • aws-access-key (either via flag or environment variable AWS_ACCESS_KEY)
  • aws-secret-key (either via flag or environment variable AWS_SECRET_KEY)
  • bucket (either via flag or environment variable BUCKET)
  • s3-region (either via flag or environment variable S3_REGION)

If you specify the s3-region, you don't need to set the endpoint URL since the correct endpoint will used automatically.

Custom S3 providers

To use a custom non-AWS S3 provider, you need to specify the endpoint as defined from your cloud provider.

Storj Network Provider

To use the Storj Network as a storage provider you need to specify the following flags:

  • provider --provider storj
  • storj-access (either via flag or environment variable STORJ_ACCESS)
  • storj-bucket (either via flag or environment variable STORJ_BUCKET)

Creating Bucket and Scope

You need to create an access grant (or copy it from the uplink configuration) and a bucket in preparation.

To get started, log in to your account and go to the Access Grant Menu and start the Wizard on the upper right.

Enter your access grant name of choice, hit Next and restrict it as necessary/preferred. Afterwards continue either in CLI or within the Browser. Next, you'll be asked for a Passphrase used as Encryption Key. Make sure to save it in a safe place. Without it, you will lose the ability to decrypt your files!

Afterwards, you can copy the access grant and then start the startup of the transfer.sh endpoint. It is recommended to provide both the access grant and the bucket name as ENV Variables for enhanced security.

Example:

export STORJ_BUCKET=<BUCKET NAME>
export STORJ_ACCESS=<ACCESS GRANT>
transfer.sh --provider storj

Google Drive Usage

For the usage with Google drive, you need to specify the following options:

  • provider
  • gdrive-client-json-filepath
  • gdrive-local-config-path
  • basedir

Creating Gdrive Client Json

You need to create an OAuth Client id from console.cloud.google.com, download the file, and place it into a safe directory.

Usage example

go run main.go --provider gdrive --basedir /tmp/ --gdrive-client-json-filepath /[credential_dir] --gdrive-local-config-path [directory_to_save_config]

Shell functions

Bash, ash and zsh (multiple files uploaded as zip archive)

Add this to .bashrc or .zshrc or its equivalent
transfer() (if [ $# -eq 0 ]; then printf "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>\n">&2; return 1; fi; file_name=$(basename "$1"); if [ -t 0 ]; then file="$1"; if [ ! -e "$file" ]; then echo "$file: No such file or directory">&2; return 1; fi; if [ -d "$file" ]; then cd "$file" || return 1; file_name="$file_name.zip"; set -- zip -r -q - .; else set -- cat "$file"; fi; else set -- cat; fi; url=$("$@" | curl --silent --show-error --progress-bar --upload-file "-" "https://transfer.sh/$file_name"); echo "$url"; )

Now you can use transfer function

$ transfer hello.txt

Bash and zsh (with delete url, delete token output and prompt before uploading)

Add this to .bashrc or .zshrc or its equivalent
Expand

transfer()
{
    local file
    declare -a file_array
    file_array=("${@}")

    if [[ "${file_array[@]}" == "" || "${1}" == "--help" || "${1}" == "-h" ]]
    then
        echo "${0} - Upload arbitrary files to \"transfer.sh\"."
        echo ""
        echo "Usage: ${0} [options] [<file>]..."
        echo ""
        echo "OPTIONS:"
        echo "  -h, --help"
        echo "      show this message"
        echo ""
        echo "EXAMPLES:"
        echo "  Upload a single file from the current working directory:"
        echo "      ${0} \"image.img\""
        echo ""
        echo "  Upload multiple files from the current working directory:"
        echo "      ${0} \"image.img\" \"image2.img\""
        echo ""
        echo "  Upload a file from a different directory:"
        echo "      ${0} \"/tmp/some_file\""
        echo ""
        echo "  Upload all files from the current working directory. Be aware of the webserver's rate limiting!:"
        echo "      ${0} *"
        echo ""
        echo "  Upload a single file from the current working directory and filter out the delete token and download link:"
        echo "      ${0} \"image.img\" | awk --field-separator=\": \" '/Delete token:/ { print \$2 } /Download link:/ { print \$2 }'"
        echo ""
        echo "  Show help text from \"transfer.sh\":"
        echo "      curl --request GET \"https://transfer.sh\""
        return 0
    else
        for file in "${file_array[@]}"
        do
            if [[ ! -f "${file}" ]]
            then
                echo -e "\e[01;31m'${file}' could not be found or is not a file.\e[0m" >&2
                return 1
            fi
        done
        unset file
    fi

    local upload_files
    local curl_output
    local awk_output

    du -c -k -L "${file_array[@]}" >&2
    # be compatible with "bash"
    if [[ "${ZSH_NAME}" == "zsh" ]]
    then
        read $'upload_files?\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$') to "transfer.sh"? (Y/n): \e[0m'
    elif [[ "${BASH}" == *"bash"* ]]
    then
        read -p $'\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$') to "transfer.sh"? (Y/n): \e[0m' upload_files
    fi

    case "${upload_files:-y}" in
        "y"|"Y")
            # for the sake of the progress bar, execute "curl" for each file.
            # the parameters "--include" and "--form" will suppress the progress bar.
            for file in "${file_array[@]}"
            do
                # show delete link and filter out the delete token from the response header after upload.
                # it is important to save "curl's" "stdout" via a subshell to a variable or redirect it to another command,
                # which just redirects to "stdout" in order to have a sane output afterwards.
                # the progress bar is redirected to "stderr" and is only displayed,
                # if "stdout" is redirected to something; e.g. ">/dev/null", "tee /dev/null" or "| <some_command>".
                # the response header is redirected to "stdout", so redirecting "stdout" to "/dev/null" does not make any sense.
                # redirecting "curl's" "stderr" to "stdout" ("2>&1") will suppress the progress bar.
                curl_output=$(curl --request PUT --progress-bar --dump-header - --upload-file "${file}" "https://transfer.sh/")
                awk_output=$(awk \
                    'gsub("\r", "", $0) && tolower($1) ~ /x-url-delete/ \
                    {
                        delete_link=$2;
                        print "Delete command: curl --request DELETE " "\""delete_link"\"";

                        gsub(".*/", "", delete_link);
                        delete_token=delete_link;
                        print "Delete token: " delete_token;
                    }

                    END{
                        print "Download link: " $0;
                    }' <<< "${curl_output}")

                # return the results via "stdout", "awk" does not do this for some reason.
                echo -e "${awk_output}\n"

                # avoid rate limiting as much as possible; nginx: too many requests.
                if (( ${#file_array[@]} > 4 ))
                then
                    sleep 5
                fi
            done
            ;;

        "n"|"N")
            return 1
            ;;

        *)
            echo -e "\e[01;31mWrong input: '${upload_files}'.\e[0m" >&2
            return 1
    esac
}

Sample output

$ ls -lh
total 20M
-rw-r--r-- 1 <some_username> <some_username> 10M Apr  4 21:08 image.img
-rw-r--r-- 1 <some_username> <some_username> 10M Apr  4 21:08 image2.img
$ transfer image*
10240K  image2.img
10240K  image.img
20480K  total
Do you really want to upload the above files (2) to "transfer.sh"? (Y/n):
######################################################################################################################################################################################################################################## 100.0%
Delete command: curl --request DELETE "https://transfer.sh/wJw9pz/image2.img/mSctGx7pYCId"
Delete token: mSctGx7pYCId
Download link: https://transfer.sh/wJw9pz/image2.img

######################################################################################################################################################################################################################################## 100.0%
Delete command: curl --request DELETE "https://transfer.sh/ljJc5I/image.img/nw7qaoiKUwCU"
Delete token: nw7qaoiKUwCU
Download link: https://transfer.sh/ljJc5I/image.img

$ transfer "image.img" | awk --field-separator=": " '/Delete token:/ { print $2 } /Download link:/ { print $2 }'
10240K  image.img
10240K  total
Do you really want to upload the above files (1) to "transfer.sh"? (Y/n):
######################################################################################################################################################################################################################################## 100.0%
tauN5dE3fWJe
https://transfer.sh/MYkuqn/image.img

Contributions

Contributions are welcome.

Creators

Remco Verhoef

Uvis Grinfelds

Maintainer

Andrea Spacca

Stefan Benten

Copyright and License

Code and documentation copyright 2011-2018 Remco Verhoef. Code and documentation copyright 2018-2020 Andrea Spacca. Code and documentation copyright 2020- Andrea Spacca and Stefan Benten.

Code released under the MIT license.

transfer.sh's People

Contributors

adamantike avatar ahxxm avatar am97 avatar aspacca avatar bookmoons avatar buckket avatar cglewis avatar cheeseandcereal avatar computeralex92 avatar dependabot[bot] avatar dessant avatar eteeselink avatar justanotherarchivist avatar keks24 avatar kugiyasan avatar limitedeternity avatar melongbob avatar n6udp avatar n8225 avatar neydroid avatar nl5887 avatar sente avatar snowphone avatar stefanbenten avatar theassassin avatar thesoumilarora avatar tofuschnitzel avatar tombyrer avatar uvisgrinfelds avatar ysndr 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  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

transfer.sh's Issues

Doesn't work on MacOS X 10.6

Process: launchd [11727]
Path: /Users/melody/Downloads/transfer.sh.app/Contents/MacOS/applet
Identifier: com.apple.ScriptEditor.id.transfer-sh
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: launchd [124]

Date/Time: 2015-03-30 01:01:51.863 +1100
OS Version: Mac OS X 10.6.8 (10K549)
Report Version: 6

Interval Since Last Report: 69981219 sec
Crashes Since Last Report: 836
Per-App Crashes Since Last Report: 4
Anonymous UUID: FC5CA901-E8AF-4044-8E64-7AFB441F5ECA

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xfffffffffffffff8
Crashed Thread: Unknown

Backtrace not available

Unknown thread crashed with X86 Thread State (64-bit):
rax: 0x0000000000000055 rbx: 0x0000000000000000 rcx: 0x0000000000000000 rdx: 0x0000000000000000
rdi: 0x0000000000000000 rsi: 0x0000000000000000 rbp: 0x0000000000000000 rsp: 0x0000000000000000
r8: 0x0000000000000000 r9: 0x0000000000000000 r10: 0x0000000000000000 r11: 0x0000000000000000
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x0000000000000000 r15: 0x0000000000000000
rip: 0x00007fff5fc01028 rfl: 0x0000000000010203 cr2: 0xfffffffffffffff8

Binary images description not available

Model: iMac8,1, BootROM IM81.00C1.B00, 2 processors, Intel Core 2 Duo, 2.4 GHz, 4 GB, SMC 1.29f1
Graphics: ATI Radeon HD 2400 XT, ATI Radeon HD 2400, PCIe, 128 MB
Memory Module: global_name
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8C), Broadcom BCM43xx 1.0 (5.10.131.42.4)
Bluetooth: Version 2.4.5f3, 2 service, 19 devices, 1 incoming serial ports
Network Service: Ethernet, Ethernet, en0
Network Service: Ethernet Adaptor (en3), Ethernet, en3
Serial ATA Device: Hitachi HDP725025GLA380, 232.89 GB
Parallel ATA Device: MATSHITADVD-R UJ-875
USB Device: Built-in iSight, 0x05ac (Apple Inc.), 0x8502, 0xfd400000 / 3
USB Device: USB 2.0 Hub [MTT], 0x1a40 (TERMINUS TECHNOLOGY INC.), 0x0201, 0xfd100000 / 2
USB Device: nanoKONTROL2, 0x0944 (KORG, Inc.), 0x0117, 0xfd120000 / 7
USB Device: USB to Serial-ATA bridge, 0x059b (Iomega Corporation), 0x0577, 0xfd170000 / 6
USB Device: iMic USB audio system, 0x077d, 0x07af, 0xfd140000 / 5
USB Device: QX61, 0x13b2, 0x0077, 0xfd150000 / 4
USB Device: IR Receiver, 0x05ac (Apple Inc.), 0x8242, 0x5d100000 / 2
USB Device: BRCM2046 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0x1a100000 / 2
USB Device: Bluetooth USB Host Controller, 0x05ac (Apple Inc.), 0x820f, 0x1a110000 / 4
USB Device: 2.4G Keyboard Mouse, 0x062a (ProVision Technology, Inc.), 0x4101, 0x3a200000 / 2

Install on a raspberry pi?

I can't seem to get docker to host it's own transfer.sh site. `pi@raspberrypi:/opt $ cd transfer.sh
pi@raspberrypi:/opt/transfer.sh $ docker build -t transfersh .

Sending build context to Docker daemon 2.358 MB
Step 1 : FROM golang
latest: Pulling from library/golang
efd26ecc9548: Pull complete
a3ed95caeb02: Pull complete
d1784d73276e: Pull complete
72e581645fc3: Pull complete
01ce90e06b06: Pull complete
666886c80650: Pull complete
2b9aef313bfc: Pull complete
a47658d1602e: Pull complete
Digest: sha256:d93f678ece9be3e1b5c8d845892fd5d469c8cb8aef335cee8df63c41d0f60818
Status: Downloaded newer image for golang:latest
---> a274681c9df8
Step 2 : MAINTAINER Remco Verhoef [email protected]
---> Running in 819bc2ab9d32
---> 1bc96b6d1c8c
Removing intermediate container 819bc2ab9d32
Step 3 : RUN mkdir -p /go/src/app
---> Running in 772ee128ed22
exec format error
Cannot start container 772ee128ed223d3e66ae4a779dec07375e5d06d33f81404029976973e6712504: [9] System error: exec format error
pi@raspberrypi:/opt/transfer.sh $ docker run --publish 8080:8080 --rm transfersh --provider local --basedir /tmp/
Unable to find image 'transfersh:latest' locally
Pulling repository docker.io/library/transfersh
docker: Error: image library/transfersh not found.
See 'docker run --help'.
pi@raspberrypi:/opt/transfer.sh`

Any ways I can host it on my raspberry pi? if so any help is appreciated :)

curl: no URL specified!

So i just went to your website copied this:

# Add this to .bashrc or its equivalent 
transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi 
tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; } 

I have save it in my .zshrc and when i run transfer test.txt i get this error:

Any idea why and how to fix it?

Support for mkv video files

Hi there,

Many thanks for transfer.sh! I regularly use it to share some files.

Just now I wanted to share a screencast that I had created with simplescreenrecorder on my Linux machine: https://transfer.sh/RzaoH/screencast.mkv

The default format is mkv which currently does not seem to be supported.

Would it be possible to support mkv files?

Thankfully,

Robert

Opening uploaded html file link to browser causes browser to execute the javascript in the file

When you upload an html file and open the given url in the browser (tested on Chrome) the javascript that was in the file executes. For example, below I have an html file that redirects the user to another website, so when I open the link to the file on transfer.sh it ends up executing the redirect code instead of just showing me a preview.

Sample code:

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="1;url=http://www.sample.com">
        <script type="text/javascript">
            window.location.href = "http://www.sample.com"
        </script>
        <title>Page Redirection</title>
    </head>
    <body>
        <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
        If you are not redirected automatically, follow the <a href='http://www.sample.com'>link to sample</a>
    </body>
</html>

mktemp fails on Peppermint 4 Linux

Steps to recreate.

Running on Peppermint 4 Linux.

$ transfer() {
> # write to output to tmpfile because of progress bar
> tmpfile=$( mktemp -t transfer )
> curl --progress-bar --upload-file $1 https://transfer.sh/$(basename $1) >> $tmpfile
> cat $tmpfile
> rm -f $tmpfile;
> }
$ alias transfer=transfer
$ transfer /var/log/syslog
mktemp: too few X's in template ‘transfer’
-bash: $tmpfile: ambiguous redirect

What's going wrong?

In the version of mktemp on Peppermint 4 Linux, template requires at least 3 consecutive XXX's.

$ mktemp --help
mktemp --help
Usage: mktemp [OPTION]... [TEMPLATE]
Create a temporary file or directory, safely, and print its name.
TEMPLATE must contain at least 3 consecutive 'X's in last component.
If TEMPLATE is not specified, use tmp.XXXXXXXXXX, and --tmpdir is implied.
Files are created u+rw, and directories u+rwx, minus umask restrictions.

  -d, --directory     create a directory, not a file
  -u, --dry-run       do not create anything; merely print a name (unsafe)
  -q, --quiet         suppress diagnostics about file/dir-creation failure
      --suffix=SUFF   append SUFF to TEMPLATE.  SUFF must not contain slash.
                        This option is implied if TEMPLATE does not end in X.
      --tmpdir[=DIR]  interpret TEMPLATE relative to DIR.  If DIR is not
                        specified, use $TMPDIR if set, else /tmp.  With
                        this option, TEMPLATE must not be an absolute name.
                        Unlike with -t, TEMPLATE may contain slashes, but
                        mktemp creates only the final component

  -p DIR              use DIR as a prefix; implies -t [deprecated]
  -t                  interpret TEMPLATE as a single file name component,
                        relative to a directory: $TMPDIR, if set; else the
                        directory specified via -p; else /tmp [deprecated]

      --help     display this help and exit
      --version  output version information and exit

Report mktemp bugs to [email protected]
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'mktemp invocation'

Workaround

So the following workaround works.

transfer() {
# write to output to tmpfile because of progress bar
tmpfile=$( mktemp -t transferXXX )
curl --progress-bar --upload-file $1 https://transfer.sh/$(basename $1) >> $tmpfile;
cat $tmpfile;
rm -f $tmpfile;
}

alias transfer=transfer

DELETE a file ?

curl -X DELETE https://transfer.sh/xf54d/myfile.password
would be awesome.

upload a file to local host returns 301

I am installing the app using docker on my laptop. I get 301 when trying to upload a file.
curl -v --upload-file ./hello.txt http://localhost:8080/hello.txt

* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> PUT /hello.txt HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:8080
> Accept: */*
> Content-Length: 10
> Expect: 100-continue
> 
< HTTP/1.1 301 Moved Permanently
< Location: https://transfer.sh/hello.txt
* Server Transfer.sh HTTP Server 1.0 is not blacklisted
< Server: Transfer.sh HTTP Server 1.0
< X-Made-With: <3 by DutchCoders
< X-Served-By: Proudly served by DutchCoders
< Date: Mon, 08 Dec 2014 21:33:32 GMT
< Content-Length: 0
< Content-Type: text/plain; charset=utf-8
* HTTP error before end of send, stop sending

encryption example does not work when using the `transfer` command

The encryption example does not work when using the transfer command:

cat crm.py | gpg -ac -o- | transfer:

No arguments specified. Usage:
echo transfer /tmp/test.md
cat /tmp/test.md | transfer test.md
gpg: [stdout]: write error: Broken pipe
gpg: iobuf_flush failed on close: file write error```

Transfer.sh alias mangles output for hidden onion service

https://gist.github.com/BoBeR182/27ef189e6a61ca5add5c123c558a29d4
Is what I am using for my alias

When doing the following command.

transfer files.zip

I get an incorrect URL with an invalid SSL cert. See log below...

[bober@boberbot][~]% transfer files.zip

################################################################## 100.0%

https://jxm5d6emw5rknovg.onion/9EZaY/files.zip

If a file is uploaded via the onion hidden service the output from the server should be without SSL.

Please allow for uppercase download URLs

Right now it seems that the download URLs returneed from transfer.sh are always lowercase. Please allow for uppercase characters in download URLs as well.

If that is already possible, please show me how.

Add support for directories in the alias

Hi guys,

I think it would be nice to add directory support in the given alias. We could first create a tarball of it and then upload it. Something like this:

transfer() {
  file=$1

  if [[ -d $1 ]]; then
    file=$(basename $1).tar.gz
    tar cvzf $file $1
  fi

  # write to output to tmpfile because of progress bar
  tmpfile=$( mktemp -t transferXXX )
  curl --progress-bar --upload-file $file https://transfer.sh/$(basename $file) >> $tmpfile
  cat $tmpfile;
  rm -f $tmpfile;
}

What do you think?

Not uploading files when filename has Spaces

I'm getting upload errors when trying to upload a file with spaces, even when correctly escaping the spaces with a backslash.

Example: transfer Getting\ Started\ With\ Git.pdf

Errors when trying the above command:

curl: Can't open 'Getting'!
curl: try 'curl --help' or 'curl --manual' for more information

curl: (6) Could not resolve host: With

curl: (6) Could not resolve host: Git.png
######################################################################## 100.0%

curl: (6) Could not resolve host: Started

curl: (6) Could not resolve host: With

curl: (6) Could not resolve host: Git.png
Not Found

Running in Docker daemon mode

Most likely I'm misunderstanding something but how do I get this running in daemon mode in Docker? I tried the following but I could not curl a file to port 8085.

docker run -d -p 8085:8080 --name transfersh transfersh

Gave this error:

curl --upload-file ./test123.txt http://192.168.1.89:8085/
curl: (7) Failed to connect to 192.168.1.89 port 8085: Connection refused

OK: was passing the Go params in the wrong place. This works without giving the connection refuse error but the files are not uploaded. i.e.: /tmp/ is empty after the curl command.

docker run -d -p 8085:8080 --name transfersh transfersh --basedir /tmp/ --provider local

Logs show this only. Is there a way to up the level to debug?:

10/14/2016 12:56:37 PMNumber of CPUs:  2
10/14/2016 12:56:37 PMProfiled listening at: :6060
10/14/2016 12:56:37 PM2016/10/14 16:56:37 Transfer.sh server started. :
10/14/2016 12:56:37 PMlistening on port: 8080
10/14/2016 12:56:37 PMusing temp folder: /tmp
10/14/2016 12:56:37 PMusing storage provider: local
10/14/2016 12:56:37 PM2016/10/14 16:56:37 ---------------------------

Alias for fish-shell

I would like to add this function for fish-shell somewhere in the documentation, but I'm unsure as to where.

function transfer --description 'Upload a file to transfer.sh'
    if [ $argv[1] ]
        # write to output to tmpfile because of progress bar
        set -l tmpfile ( mktemp -t transferXXX )
        curl --progress-bar --upload-file $argv[1] https://transfer.sh/(basename $argv[1]) >> $tmpfile
        cat $tmpfile
        command rm -f $tmpfile
    else
        echo 'usage: transfer FILE_TO_TRANSFER'
    end
end

how to build this, its not working ubuntu 15.04 server

not working . go build -o transfersh-server/*.go

go version
go version go1.3.3 linux/amd64

/go/transfer.sh-master# go build -o transfersh-server/_.go
transfersh-server/main.go:43:2: cannot find package "github.com/PuerkitoBio/ghost/handlers" in any of:
/usr/lib/go/src/pkg/github.com/PuerkitoBio/ghost/handlers (from $GOROOT)
/root/go/src/github.com/PuerkitoBio/ghost/handlers (from $GOPATH)
transfersh-server/handlers.go:52:2: cannot find package "github.com/dutchcoders/go-clamd" in any of:
/usr/lib/go/src/pkg/github.com/dutchcoders/go-clamd (from $GOROOT)
/root/go/src/github.com/dutchcoders/go-clamd (from $GOPATH)
transfersh-server/virustotal.go:30:2: cannot find package "github.com/dutchcoders/go-virustotal" in any of:
/usr/lib/go/src/pkg/github.com/dutchcoders/go-virustotal (from $GOROOT)
/root/go/src/github.com/dutchcoders/go-virustotal (from $GOPATH)
transfersh-server/utils.go:35:2: cannot find package "github.com/goamz/goamz/aws" in any of:
/usr/lib/go/src/pkg/github.com/goamz/goamz/aws (from $GOROOT)
/root/go/src/github.com/goamz/goamz/aws (from $GOPATH)
transfersh-server/storage.go:14:2: cannot find package "github.com/goamz/goamz/s3" in any of:
/usr/lib/go/src/pkg/github.com/goamz/goamz/s3 (from $GOROOT)
/root/go/src/github.com/goamz/goamz/s3 (from $GOPATH)
transfersh-server/utils.go:37:2: cannot find package "github.com/golang/gddo/httputil/header" in any of:
/usr/lib/go/src/pkg/github.com/golang/gddo/httputil/header (from $GOROOT)
/root/go/src/github.com/golang/gddo/httputil/header (from $GOPATH)
transfersh-server/handlers.go:54:2: cannot find package "github.com/gorilla/mux" in any of:
/usr/lib/go/src/pkg/github.com/gorilla/mux (from $GOROOT)
/root/go/src/github.com/gorilla/mux (from $GOPATH)
transfersh-server/handlers.go:55:2: cannot find package "github.com/kennygrant/sanitize" in any of:
/usr/lib/go/src/pkg/github.com/kennygrant/sanitize (from $GOROOT)
/root/go/src/github.com/kennygrant/sanitize (from $GOPATH)
transfersh-server/handlers.go:56:2: cannot find package "github.com/russross/blackfriday" in any of:
/usr/lib/go/src/pkg/github.com/russross/blackfriday (from $GOROOT)
/root/go/src/github.com/russross/blackfriday (from $GOPATH)
root@vp34534534:
/go/transfer.sh-master# go run transfersh-server/_.go -provider=local --port 8080 --temp=/tmp/ --basedir=/tmp/
transfersh-server/main.go:43:2: cannot find package "github.com/PuerkitoBio/ghost/handlers" in any of:
/usr/lib/go/src/pkg/github.com/PuerkitoBio/ghost/handlers (from $GOROOT)
/root/go/src/github.com/PuerkitoBio/ghost/handlers (from $GOPATH)
transfersh-server/handlers.go:52:2: cannot find package "github.com/dutchcoders/go-clamd" in any of:
/usr/lib/go/src/pkg/github.com/dutchcoders/go-clamd (from $GOROOT)
/root/go/src/github.com/dutchcoders/go-clamd (from $GOPATH)
transfersh-server/virustotal.go:30:2: cannot find package "github.com/dutchcoders/go-virustotal" in any of:
/usr/lib/go/src/pkg/github.com/dutchcoders/go-virustotal (from $GOROOT)
/root/go/src/github.com/dutchcoders/go-virustotal (from $GOPATH)
transfersh-server/utils.go:35:2: cannot find package "github.com/goamz/goamz/aws" in any of:
/usr/lib/go/src/pkg/github.com/goamz/goamz/aws (from $GOROOT)
/root/go/src/github.com/goamz/goamz/aws (from $GOPATH)
transfersh-server/storage.go:14:2: cannot find package "github.com/goamz/goamz/s3" in any of:
/usr/lib/go/src/pkg/github.com/goamz/goamz/s3 (from $GOROOT)
/root/go/src/github.com/goamz/goamz/s3 (from $GOPATH)
transfersh-server/utils.go:37:2: cannot find package "github.com/golang/gddo/httputil/header" in any of:
/usr/lib/go/src/pkg/github.com/golang/gddo/httputil/header (from $GOROOT)
/root/go/src/github.com/golang/gddo/httputil/header (from $GOPATH)
transfersh-server/handlers.go:54:2: cannot find package "github.com/gorilla/mux" in any of:
/usr/lib/go/src/pkg/github.com/gorilla/mux (from $GOROOT)
/root/go/src/github.com/gorilla/mux (from $GOPATH)
transfersh-server/handlers.go:55:2: cannot find package "github.com/kennygrant/sanitize" in any of:
/usr/lib/go/src/pkg/github.com/kennygrant/sanitize (from $GOROOT)
/root/go/src/github.com/kennygrant/sanitize (from $GOPATH)
transfersh-server/handlers.go:56:2: cannot find package "github.com/russross/blackfriday" in any of:
/usr/lib/go/src/pkg/github.com/russross/blackfriday (from $GOROOT)
/root/go/src/github.com/russross/blackfriday (from $GOPATH)

Add raw link to the file

transfer.sh seems to do some kind of user agent sniffing and it displays the files in a HTML wrapper in the browser. Which is fine, but it should also display a raw link to the file which does not ever add the wrapper because now it is impossible to view images in their full size or use JSON-formatting extensions to view json files in browser.

support Range request from HTTP Header

Hi,

If you want to support Range requests, the easy way is you need something like

http.ServeContent(w, r, filename, modTime, seeker)

in your getHandler instead of the io.Copy.

This will allow seeking for media files.

Change color of video player

http://i.imgur.com/Gqx7rfv.png
As you may have noticed buttons under the video are hard to see when you are looking at the player for the first time. I actually had a few situations where I was sending .mp4 and people receiving the link thought that they actually have to download the video instead of just playing it.
Solution is pretty simple, just make buttons brighter than the background, because right now it's really hard to tell if it's just some thumbnail or the actual player.

Multiple Files?

Hello,

im trying to upload multiple files within a folder to transfer.sh

Any idea how to do so?

transfer * > /home/kvm1/www/uploads.txt

syntax error in bashrc script

Both the transfer.sh script at gist and the two line .bashrc version in 'sample use cases' return ...

syntax error near unexpected token `('

... when running in bash via Manjaro Linux.

In the case of calling the script from my bashrc I get ...

[kevjo@manjaro ~]$ transfer test-transfer.txt

bash: /home/kevjo/Software/Scripts/transfer.sh: line 14: syntax error near unexpected token `('

bash: /home/kevjo/Software/Scripts/transfer.sh: line 14: `transfer() { '

... Inserting the two line snippet version directly in .bashrc results in similar, but with an error line number relevant to location in the bashrc file itself.

Might something be missing from within or preceding the round brackets at "transfer()" perhaps?

Docker run command errors: Error while creating storage

Here are the steps I took:

cd ./transfer.sh/
docker build -t transfersh .
docker run --publish 8080:8080 --rm transfersh --provider local --basedir /tmp/

And the error:

2014/12/08 01:34:19 Error while creating storage.
panic: Error while creating storage.

goroutine 16 [running]:
runtime.panic(0x739160, 0xc2080354e0)
        /usr/src/go/src/pkg/runtime/panic.c:279 +0xf5
log.Panic(0xc2080fde80, 0x1, 0x1)
        /usr/src/go/src/pkg/log/log.go:307 +0xb6
main.main()
        /go/src/app/main.go:162 +0x1c72

goroutine 19 [finalizer wait]:
runtime.park(0x423130, 0xacad10, 0xac8709)
        /usr/src/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0xacad10, 0xac8709)
        /usr/src/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
        /usr/src/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
        /usr/src/go/src/pkg/runtime/proc.c:1445

Ubuntu 14.10, Docker version 1.3.2, build 39fa2fa

Return http scheme according to upload scheme (non-https support when printing share url)

https may not be always available or hard to configure if using docker containers etc.
It would be great if URL could be returned with the same http scheme that it was uploaded, now it always return https url even if upload was using http
Looks like https scheme is hardcoded:

fmt.Fprintf(w, "https://%s/%s/%s\n", ipAddrFromRemoteAddr(r.Host), token, filename)

Thanks

Run transfer.sh under Nginx

Hello, I want to run transfer.sh under Nginx but when I put transfer.sh under nginx, it redirect loop from https:// and http://. Anyone try run transfer.sh under nginx ?

transfer.sh Down?

Hi there! Thanks for making and hosting such a useful service!

It looks like there's some issue with the backend right now?

$ curl -v https://transfer.sh/
*   Trying 54.77.221.1...
* Connected to transfer.sh (54.77.221.1) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: transfer.sh
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET / HTTP/1.1
> Host: transfer.sh
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 503 Service Unavailable: Back-end server is at capacity
< Content-Length: 0
< Connection: keep-alive
<
* Connection #0 to host transfer.sh left intact

Add rate limiting

It needs rate limiting for uploading files. Maybe 15 per minute per IP?

Support getting upload slot before upload

Would be nice if there were some way to request the eventual fetch URL first, then upload to it, then fetch from it thereafter. This would simplify some scripting cases.

Possible to generate our own random token?

I have one PC that needs to share a file that changes daily with another PC remotely (not on same network).

I looked at the example provided on the website:
(Uploading is easy using curl)
$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt
https://transfer.sh/66nb8/hello.txt
(Download the file)
$ curl https://transfer.sh/66nb8/hello.txt -o hello.txt

After the upload, the curl command returns a URL with a random token ("66nb8" in the above example). The problem is the other PC doesn't know the random token, and also I want to put the download command in cron. Is it possible for us to specify our own random token that we could use over and over? The file is encrypted so security concern with plaintext URL is not a problem.

curl --upload-file ./hello.txt https://transfer.sh/3b2rd9n3kbew8jhs/hello.txt

...where 3b2rd9n3kbew8jhs is the random token chosen by the user.

Thank you.

[Question] Files with same token can't be easily zipped together?

Hi transfer.sh devs! I love the service you've provided, but I have one little question.

I notice that when I upload files over curl in batches, they'll have the same token. EG:

https://transfer.sh/IMTKN/file.name
https://transfer.sh/IMTKN/file2.name

But when I upload via the website, I get this:

https://transfer.sh/IMTKN/file.name
https://transfer.sh/IMTKN2/file2.name

I know how to write the url to bundle files under a single zip or .tar.gz, but is there a reason why files underneath the same token can't simply be referred to as https://transfer.sh/IMTKN.zip for a shorter URL? Just curious.

File names are converted to lower case

curl -v -T Gemfile.lock transfer.sh results in https://transfer.sh/:key/gemfile.lock even thou curl properly sends the PUT request with correct casing.

From the log output:

> PUT /Gemfile.lock HTTP/1.1

This gets pretty annoying when downloading the file again.

Awesome service anyway. Thanks!

API for other platforms!

Is there any web API available for transfer.sh? I'd like to develop mobile app for this service. If people are interested, I can start working on UI mockups and UX proposal right away.

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.