This repository contains a simple but powerful implementation of a file upload server written in Go. It demonstrates how to handle multiple file uploads using multipart/form-data
format and how to save these files securely on the server filesystem. This project is platform-independent and can run on macOS, Windows, and Linux.
- Multi-file upload handling using HTTP POST requests.
- Concurrent file processing to optimize performance.
- Cross-platform path handling for file operations.
- Detailed logging of file upload details and errors.
Run the file upload server go run main.go
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You need to have Go installed on your machine. To install Go, follow the instructions on the official Go website.
Clone the repository
git clone https://github.com/pillaiharish/go-file-upload-server.git
Check Private IP in you mac or windows(Note the possible urls list in console support is added in commit
hash ac15201
)
Here 192.168.0.101 is the IP on which the upload server will be hosted on home WiFi,
you visit 192.168.0.101:8989
to access webapp
harish $ ifconfig | grep 192
inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
inet 192.168.0.101 netmask 0xffffff00 broadcast 192.168.0.255
Run the upload server On you mac or window open terminal or cmd and type below in folder home path where main.go is present This assumes you have golang already downloaded, installed and path variable set in your pc. You will get possible urls for the private ips in the console
harish $ go run main.go
Server started on :8989
Possible urls: http://192.168.0.100:8989 , http://192.168.2.1:8989 ,
2024-06-30 13:23:32: File being uploaded: "IGI-Airport-1.jpeg"
This will upload your file in uploads directory, where the server is running, which can be changed in main.go
cd tests
go run load_test.go
cd tests/vegeta
./attack.sh
go install github.com/tsenart/vegeta@latest
- On macOS: brew install gnuplot
- On Linux: sudo apt-get install gnuplot
- On Windows: Download and install from the official website.
chmod +x tests/vegeta/attack.sh
./tests/vegeta/attack.sh &
gnuplot -persist tests/vegeta/plot.gp
After you're done, you might want to remove the named pip
rm /tmp/results.bin