|
1 |
| -# na |
| 1 | +# Na |
| 2 | +> Share your files with people next to you without having to send them under the ocean and back again. |
2 | 3 |
|
| 4 | +[](https://travis-ci.org/srdja/na) |
| 5 | +[](http://www.gnu.org/licenses/gpl-3.0) |
| 6 | + |
| 7 | +**Na** allows you to easily share files over a local network by serving the current working directory through HTTP. |
3 | 8 |
|
4 |
| -Share files with people next to you without having to send them under the ocean or into space and back again. |
| 9 | +## Usage |
5 | 10 |
|
| 11 | +``` |
| 12 | +na [OPTIONS] |
| 13 | +``` |
6 | 14 |
|
7 |
| -### Usage |
8 |
| -1. Place the `na` executable into a directory that you would like to share with your local network |
9 |
| -2. Run `na` |
10 | 15 |
|
11 |
| -Once it's running, others will be able to access that directory through a web page and download/upload files |
12 |
| -from it. |
| 16 | +Navigate to a directory that you wish to share and run `na`. Once it's running, |
| 17 | +you'll be able to access the files from that directory from any device that's on the same network and has |
| 18 | +a web browser (or something that understands HTTP). |
13 | 19 |
|
14 |
| -#### Building the project |
15 |
| -`cargo build` |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +## Options |
| 25 | +``` |
| 26 | +-h | --help display help and exit |
| 27 | +-d | --dir [PATH] specifies the path of the served directory (default is the working directory) |
| 28 | +-p | --port [PORT] specifies the port number (default 8888) |
| 29 | +-i | --interface [INTERFACE] specify the network interface to use (eg. `eth0`, `wlo0`, `localhost`, etc...) |
| 30 | +-r | --enable-delete enables file deletions through DELETE requests (disabled by default) |
| 31 | +-u | --disable-upload disables file uploads (enabled by default) |
| 32 | +-s | --show-directory show the path of the served directory to client (disabled by default) |
| 33 | +-l | --list-interfaces print a list of available network interfaces and exit |
| 34 | +-o | --overwrite-file if enabled, uploaded files will overwrite existing files with the same name (disabled by default) |
| 35 | +-6 | --ipv6 prefer IPv6 if available |
| 36 | +-v | --verbose verbose output |
| 37 | +``` |
| 38 | + |
| 39 | + |
| 40 | +## Using Na without a browser |
| 41 | + |
| 42 | +#### Obtaining a list of available files |
| 43 | + |
| 44 | +Lists of available resources can be obtained either in JSON at `/json`, or |
| 45 | +in a simple list form separated by a newline `\n` at `/list`. |
| 46 | + |
| 47 | + |
| 48 | +##### An example of obtaining a list of files in JSON form: |
| 49 | +``` |
| 50 | +curl -X GET http://127.0.0.1:9000/json |
| 51 | +``` |
| 52 | + |
| 53 | + |
| 54 | +```json |
| 55 | +[ |
| 56 | + { |
| 57 | + "name": ".cargo-lock", |
| 58 | + "url": "/files/.cargo-lock", |
| 59 | + "size": 0, |
| 60 | + "modified": "Tue, Aug 02 2016 02:08:53", |
| 61 | + "modified_raw": 1470096533 |
| 62 | + }, |
| 63 | + { |
| 64 | + "name": "na", |
| 65 | + "url": "/files/na", |
| 66 | + "size": 18404960, |
| 67 | + "modified": "Wed, Aug 03 2016 04:36:33", |
| 68 | + "modified_raw": 1470191793 |
| 69 | + } |
| 70 | +] |
| 71 | + |
| 72 | +``` |
| 73 | + |
| 74 | +##### An example of obtaining a simple list of URLs separated by a newline `\n`: |
| 75 | +``` |
| 76 | +curl -X GET http://127.0.0.1:9000/list |
| 77 | +``` |
| 78 | + |
| 79 | +``` |
| 80 | +/files/.cargo-lock |
| 81 | +/files/na |
| 82 | +``` |
| 83 | + |
| 84 | +##### Fetching a file: |
| 85 | +``` |
| 86 | +curl -X GET "http://127.0.0.1:9000/files/example.txt" |
| 87 | +``` |
| 88 | + |
| 89 | +##### Uploading a single file: |
| 90 | +``` |
| 91 | +curl --form "upload=@example.txt" http://127.0.0.1:9000 |
| 92 | +``` |
| 93 | +```json |
| 94 | +[ |
| 95 | + { |
| 96 | + "source_name": "README.md", |
| 97 | + "saved_name": "README.md" |
| 98 | + } |
| 99 | +] |
| 100 | +``` |
| 101 | + |
| 102 | +##### Uploading multiple files in a single request: |
| 103 | +``` |
| 104 | +curl -F "upload[]=@example.txt" -F "upload[]=@example2.txt" http://127.0.0.1:9000 |
| 105 | +``` |
| 106 | +```json |
| 107 | +[ |
| 108 | + { |
| 109 | + "source_name": "README.md", |
| 110 | + "saved_name": "README.md (1)" |
| 111 | + }, |
| 112 | + { |
| 113 | + "source_name": "build.rs", |
| 114 | + "saved_name": "build.rs" |
| 115 | + } |
| 116 | +] |
| 117 | +``` |
| 118 | + |
| 119 | +Deleting a file: |
| 120 | +``` |
| 121 | +curl -X DELETE "http://127.0.0.1:9000/files/example.txt" |
| 122 | +``` |
| 123 | +**note**: `DELETE` is disabled by default, so it needs to be enabled by passing the `-r` or `--enable-delete` flag to `na` |
| 124 | + |
| 125 | + |
| 126 | +## Installation |
| 127 | + |
| 128 | +#### Linux |
| 129 | +Download **na**: |
| 130 | +``` |
| 131 | +sudo curl -L https://github.com/srdja/na/releases/download/v0.2.0/na-linux64 -o /usr/local/bin/na |
| 132 | +``` |
| 133 | + |
| 134 | +Make **na** readable and executable for all users: |
| 135 | +``` |
| 136 | +sudo chmod a+rx /usr/local/bin/na |
| 137 | +``` |
| 138 | + |
| 139 | +#### Windows |
| 140 | +Download the **na** [executable](https://github.com/srdja/na/releases/download/v0.2.0/na-win64.exe) and place |
| 141 | +it into a directory that you wish to share, or you can put it into a directory that's in your `PATH` if you |
| 142 | +wish to use it from the command line. |
| 143 | + |
| 144 | +## Building the project |
| 145 | + |
| 146 | +Currently Rust [nightly](https://www.rust-lang.org/en-US/downloads.html) is required to build the project. |
| 147 | + |
| 148 | +- Build debug with `cargo build` |
| 149 | +- Build release with `cargo build --release` |
| 150 | + |
| 151 | + |
| 152 | +## License |
| 153 | +GPLv3+ |
| 154 | + |
| 155 | + |
| 156 | +## Contributing |
| 157 | + |
| 158 | +##### Bugs and Features |
| 159 | + |
| 160 | +If you have a feature request, or have found a bug, feel free to open a [new issue](https://github.com/srdja/na/issues/new). |
| 161 | + |
| 162 | +##### Pull Requests |
| 163 | + |
| 164 | +To get started, fork the repo to your account and then clone your fork: |
| 165 | +```bash |
| 166 | +git clone https://github.com/yourusername/na.git |
| 167 | +``` |
| 168 | +Once you're done making changes, commit your work and push it to your fork. |
| 169 | +You can then open a [pull request](https://help.github.com/articles/using-pull-requests/) from your fork to the upstream repository. |
0 commit comments