Transfer Files Between Linux and iPhone
When you use Linux for work or school, and need to transfer files between your computer and phone, you might find there's no quick and easy way like AirDrop. Those with a knack for tinkering can set up services like Samba, NFS, FTP, or NAS, but these can feel a bit heavy-handed and like overkill. The command-line software described below is lightweight and easy to use. It uses the HTTP protocol and can be used on any device with a browser.
Installing the Software
- If you don't have a Golang environment, install Golang first, such as on Ubuntu.
1sudo apt install golang
- Installation
1go install github.com/codeskyblue/gohttpserver@latest
- Default Installation Location
1➜ ~ go env | grep -i path
2GOPATH="/home/mephisto/go"
3➜ ~ ls -al /home/mephisto/go/bin
4total 10223
5drwxrwxr-x 2 mephisto mephisto 3 May 27 13:42 .
6drwxrwxr-x 4 mephisto mephisto 4 May 27 13:42 ..
7-rwxrwxr-x 1 mephisto mephisto 15626232 May 27 13:42 gohttpserver
8➜ ~
- For ease of use, you can also add this to your system's PATH environment variable.
1sudo ln -s /home/mephisto/go/bin/gohttpserver /usr/bin/gohttpserver
Simple Usage
- Listen on port 8000 and enable uploads. As shown below, the selected exchange directory is /home/mephisto/Pictures/iPhone
1➜ pwd
2/home/mephisto/Pictures/iPhone
3➜ gohttpserver -r ./ --port 8000 --upload
42022/05/27 14:08:04 httpstaticserver.go:75: root path: ./
52022/05/27 14:08:04 main.go:185: plistproxy: "https://plistproxy.herokuapp.com/plist"
62022/05/27 14:08:04 main.go:244: listening on ":8000", local address http://192.168.199.230:8000
72022/05/27 14:08:05 httpstaticserver.go:90: Started making search index
82022/05/27 14:08:05 httpstaticserver.go:92: Completed search index in 167.371µs
Open http://192.168.199.230:8000 in a computer browser. This address is mentioned in the log output above.
- Scan the QR code with your phone to access and follow the instructions to upload or download.
- Image
See the help for more features
1➜ ~ gohttpserver --help
2usage: gohttpserver [<flags>]
3
4Flags:
5-h, --help Show context-sensitive help (also try --help-long and --help-man).
6--version Show application version.
7--conf=CONF config file path, yaml format
8-r, --root=ROOT root directory, default ./
9--prefix=PREFIX url prefix, e.g. /foo
10--port=PORT listen port, default 8000
11-a, --addr=ADDR listen address, e.g. 127.0.0.1:8000
12--cert=CERT tls cert.pem path
13--key=KEY tls key.pem path
14--auth-type=AUTH-TYPE Auth type <http|openid>
15--auth-http=AUTH-HTTP HTTP basic auth (ex: user:pass)
16--auth-openid=AUTH-OPENID OpenID auth identity url
17--theme=THEME web theme, one of <black|green>
18--upload enable upload support
19--delete enable delete support
20--xheaders used when behind nginx
21--cors enable cross-site HTTP requests
22--debug enable debug mode
23-p, --plistproxy=PLISTPROXY plist proxy when server is not https
24--title=TITLE server title
25--google-tracker-id=GOOGLE-TRACKER-ID
26Set to empty to disable it
Finally, as long as this software can be run, it can theoretically be used on any device that supports the HTTP protocol, not just Linux and iPhones.
Lastmod: Friday, August 8, 2025
Copyright statement:
- All content that is not sourced is original., please do not reprint without authorization (because the typesetting is often disordered after reprinting, the content is uncontrollable, and cannot be continuously updated, etc.);
- For non-profit purposes, to deduce any content of this blog, please give the relevant webpage address of this site in the form of 'source of original text' or 'reference link' (for the convenience of readers).
See Also:
- Nginx webdav for Joplin
- Ubuntu notify-send Scheduled Notifications
- alacritty terminal use
- Building a Raspberry Pi Wireless Router