Skip to content

arussell/shareit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

shareit

Simple FTP-based file sharing from the command line

Intro

File sharing websites tend to have ads everywhere, and long running HTTP uploads of large files can be a pain in the backside, so I stopped using them a while back. Whenever I needed to share a file with someone, I'd figure out the file's MD5 sum (to avoid naming collisions), fire up Transmit (the nicest Mac FTP app by far), upload the file, rename it after uploading, then manually type the link and copy/paste the MD5'd filename in and send it to whoever I wanted to share the file with.

It was nice because I hosted the files, and didn't have to worry about my recipient seeing a bunch of ads or the file sharing service going down (or being taken down). But it had a huge downside in that it wasn't straightforward. I was doing a whole bunch of the work by hand every time I wanted to share a file with someone, which as a coder seems like I'm doing something wrong. Eventually I got round to automating it, and now it's much easier to share a file with someone quickly, just fire one line into the terminal and you're done.

Getting Started

Before you get started, you'll want to create a simple YAML file called .shareit in your home directory with your FTP config details, like this:

hostname: ftp.yourwebsite.tld
username: yourusernamegoeshere
password: yourpasswordgoeshere
path: public_html/shareit/
http_prefix: http://yourwebsite.tld/shareit/

path should exist on the FTP server, and http_prefix should be the URL that the folder is accessible at. Both path and http_prefix should also include the trailing slash.

Note that the URLs shareit generates are not secure, but they are random enough that people won't be able to guess them easily unless they know the file's exact contents. It is recommended that you disable your webserver's automatic directory indexing for the folder you define in http_prefix -- if you don't, people will be able to browse your entire collection of shared files.

Once you've set up your config file, make shareit available in your PATH by adding a symlink in /usr/bin or /usr/local/bin or something.

Usage

Using shareit is simple, all you need to do is tell it what file to upload:

$ shareit 10mb.txt
Uploading to http://yourwebsite.tld/shareit/596c35b949baf46b721744a13f76a258.txt: 10000K of 10000K (100%)
Upload complete!

License

Copyright (c) 2012 Aaron B. Russell <[email protected]>
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Aaron B. Russell nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AARON B. RUSSELL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Releases

No releases published

Packages

No packages published

Languages