HUB
Sign inSign up
trans-server-akka logo

nwtgck/trans-server-akka

By nwtgck

•Updated over 7 years ago

trans - Transmit a file anywhere

Image
0

5.4K

nwtgck/trans-server-akka repository overview

⁠trans-server

Transmit files by using only common Unix/Linux commands, curl or wget

branchTravisCICircleCICoverage
master⁠Build StatusCircleCICoverage Status
develop⁠Build StatusCircleCICoverage Status

⁠Send a file by wget

wget_send

⁠Download the file by wget

wget_get

⁠Public Server on Heroku

https://trans-akka.herokuapp.com/⁠

⁠Quick Start

You can send, download and delete a file by the following commands.

# Send a file
wget -q -O - https://trans-akka.herokuapp.com/ --post-file=./test.txt
# Downlaod the file
wget https://trans-akka.herokuapp.com/a7h
# ('a7h' is a File ID created after sending)
# Delete a file
wget -q -O - --method DELETE https://trans-akka.herokuapp.com/a7h
⁠Option explanations
  • -q: No prgress bar
  • -O -: Response to stdout

⁠Main features

  • Send/Get by only common commands, curl or wget
  • Send/Get on your browser
  • Send/Get with restrictions
    • download key
    • store duration
    • how many times you can download
  • Delete files you sent
    • without delete key
    • with delete key
  • Change File ID length (for security)
  • Encrypt and Compress file for security

⁠How to run the server

You can choose any ways you want bellow.

⁠Way 1 - Run on Docker

Docker Automated build

docker run -p 8080:8181 nwtgck/trans-server-akka

Then you can go http://localhost:8080/⁠

⁠Docker run for daemonize and data persistence

You can also run the following command for daemonize and data persistence.

docker run -d -p 8080:8181 -v $PWD/trans-db:/trans/db --restart=always nwtgck/trans-server-akka

Data will be stored in $PWD/trans-db on your host machine. (Currently file-base H2 database is used, and files sent are stored as compressed and encrypted files)

⁠Way 2 - sbt "run-main ..."

The following example runs a server on 80 port.

$ cd <this-project>
$ ./make-keystore.sh
$ sbt "run-main io.github.nwtgck.trans_server.Main --http-port=8282"
⁠Way 3 - Making a jar
⁠1. Make a keystore
$ cd <this-project>
$ ./make-keystore.sh
⁠2. Make a jar
$ cd <this-project>
$ sbt assembly

(It takes a time)

⁠3. Run the jar
$ java -jar target/scala-2.11/trans-server-akka.jar --http-port=8282 --https-port=4433

⁠How to send a file to the server

⁠Way 1 - curl

The following example is sending ../test.txt

$ curl https://trans-akka.herokuapp.com/ --data-binary @../test.txt
⁠output
ab2

The server response, ab2 is a File ID to get ../test.txt

⁠Way 2 - wget

The following example sends ../test.txt

$ wget -q -O - https://trans-akka.herokuapp.com/ --post-file=../test.txt
  • -q is for non-progress bar
  • -O - is to output STDOUT
⁠output
9vi

The server response, 9vi is a File ID to get ../test.txt

⁠Way 3 - wc & cat & nc

This way is for a user which can't use curl command.

The following example sends sounds.zip.

⁠1. Get a file byte
$ wc -c  < sounds.zip
⁠output
1161257298 # Use it later
⁠2. Create header.txt
POST / HTTP/1.1
Host: localhost:4343
Content-Length: 1161257298

Don't forget the end of '\n'

⁠3. Send a file by HTTP request
$ cat header.txt sounds.zip | nc localhost 4343

The response is bellow.

HTTP/1.1 200 OK
Server: akka-http/10.0.5
Date: Sun, 23 Apr 2017 04:22:32 GMT
Connection: close
Content-Type: text/plain; charset=UTF-8
Content-Length: 4

6oz

6oz is FILE ID.

⁠How to get a file from the server

⁠Way 1 - wget
$ wget https://trans-akka.herokuapp.com/ab2

ab2 is a File ID.

⁠Way 2 - curl
$ curl https://trans-akka.herokuapp.com/ab2 > test.txt

ab2 is a File ID.

⁠Way 3 - Using a Browser

Open https://trans-akka.herokuapp.com/ab2 on your browser

ab2 is a File ID.

⁠Sending-options

Here is options you can use when sending

GET parameterdefault valuedecription
duration1 hourStore duration/life
get-timesinfiniteHow many times you can download
id-length3Length of File ID
deletabletrueWhether a file can be deleted
delete-keynothingKey for deletion
secure-charfalseWhether more complex characters are used for File ID
⁠An example with options
wget -q -O - 'https://trans-akka.herokuapp.com/?duration=30s&get-times=1&id-length=16&delete-key=mykey1234&secure-char' --post-file=./hello.txt

The command means

  • duration is 30 seconds
  • download once
  • File ID length is 16
  • The file is deletable and key is 'mykey1234'
  • Use more complex characters for File ID
⁠Available duration examples
  • 10s - 10 seconds
  • 2m - 2 minutes
  • 12h - 12 hours
  • 25d - 25 days
⁠Usage of deletable

All bellow are valid usages.

'https://trans-akka.herokuapp.com/?deletable'
# (same meaning as `deletable=true`)
'https://trans-akka.herokuapp.com/?deletable=true'
'https://trans-akka.herokuapp.com/?deletable=false'
⁠Set download key
curl -u dummy_user:mypass123 -T ./hello.txt  https://trans-akka.herokuapp.com

When you don't want to type key in command, you can use -u dummy_user instead of -u dummy_user:mypass123. Then, curl provide you a password prompt.

NOTE: dummy_user can be change any name including empty ''.

⁠Get with download key
curl -u dummy_user:mypass123 https://trans-akka.herokuapp.com/yk2

NOTE: The server doesn't check user name. So, you can use any name for user name, not only "dummy_user".

⁠Delete file

⁠delete without delete key

# wget version
wget -q -O - --method=DELETE 'https://trans-akka.herokuapp.com/vua'
# curl version
curl -X DELETE 'https://trans-akka.herokuapp.com/vua'

(vua is a File ID)

⁠delete with delete key

# wget version
wget -q -O - --method=DELETE 'https://trans-akka.herokuapp.com/6em?delete-key=1234'
# curl version
curl -X DELETE 'https://trans-akka.herokuapp.com/6em?delete-key=1234'

⁠My Note

MYNOTE.md⁠

Tag summary

Content type

Image

Digest

Size

95.8 MB

Last updated

over 7 years ago

docker pull nwtgck/trans-server-akka