Easier file sharing

Recently, I’ve been sharing a lot of (big and small) files with my colleagues and my girlfriend. Yes, yes…I know. This is nothing new. You can always share files over email, Dropbox, Slack, using USB data drive… You name it.

This particular post is about sharing files with people who are in the same local network as you are. That means you can share files easily with your colleagues and family. I am not talking about Airdrop or any similar related service.

I am talking about sharing files using HTTP protocol (for those who are not familiar with it, I am talking about sharing over Internet browser – Chrome, Firefox, IE (god forbid)).

Whom is this for?

This is not for average Joe or plain Jane computer user. If you know how to run commands in terminal, this is for you. I am sorry average Joe and plain Jane :(.

Using all of those methods I mentioned above are great and you should keep using them. But this is intended mainly for us, lazy terminal users.

What problem am I trying to solve?

That’s a good question, if I may. How many times were you trying to transfer any big file from one computer to another computer? Let’s say you wanted to watch a movie on another computer. You would probably grab nearest USB drive, copy movie to the drive, unplug it, plug it to another computer, realize that your girlfriend’s computer cannot read USB data (since she is using Windows and you formatted your drive as ext3)…ARGH!…you get the point.

Or you wanted to transfer big file to your work buddy but you cannot because you are using free version of Slack. Then you scp file to buddy’s computer or any common server you both can connect to.

This can sometimes be pain in the butt :).

OK. How to run this thingy of yours?

Another good question! Running is pretty much straight forward. You need to have Docker installed. Once you do, all you need to do is run:

docker run -i -t -p 5000:5000 -v $(pwd):/shareme vizualni/shareme:1.0 

This will create HTTP server which will be available to all of the people in your network. Depending on NAT settings it could be possible that it’s publicly available. But you are smart! You should take care of that ;).
Anyway, HTTP server is listening on port 5000 and shares your current folder.
If you were to open http://your_ip:5000 in your browser you would get something like this:

shareme

Don’t mind the design part. I am not a designer so it might look like a bunch of cr*p :).

You can see all files and folders in currently shared folder. By clicking on a file, it will automatically start downloading it. When clicking on a folder, you will see content of that folder. You know, just like Finder or #whateverThatThingOnWindowsIsCalled.

It’s nothing new. Just easier way of sharing files.

All you need to do is, give your friend/colleague/girlfriend/boyfriend/husband/wife/grandparent link http://your_ip:5000 and let them download anything you and they would like.

Once you are done, press CTRL + C to stop it.

But isn’t this a little bit long command?

Yes it is. That’s why you can run this in your terminal to make it easier to share current folder you are in (think of it as an install script):

alias shareme="docker run -i -t -p 5000:5000 -v $(pwd):/shareme vizualni/shareme:1.0"
echo alias $(alias shareme) >> ~/.bash_rc

Or if you are using ZSH replace ~/.bash_rc with ~/.zshrc. Change that file accordingly.

Instead of running that long command, all you need to do is run shareme.

Be careful what you share!

As I previously mentioned this will share all files and folders in currently shared folder. That means if you share your home folder, everybody could see your private files (including your private keys – if you have default settings).

Help wanted!

If you would like to add new feature (maybe upload feature, or download folder as zip) feel free to create merge request and I would happily merge it. Also, if you are designer or (front)developer please make it prettier :). You can find whole source code on github.

Closing words.

I haven’t invented anything new with this. I just made it easier to share files and folders. If you already know for any existing solution or method please let me know :).


Also published on Medium.

 

Vizualni

Programmer. Passionate about algorithms and data structures. Enjoys clean and readable code. Loves hackerrank and similar pages.

 

Leave a Reply

%d bloggers like this: