Skip to content

Clone this repository to enable multi-device file uploads to a web app on a laptop over Wi-Fi using HTTP.

Notifications You must be signed in to change notification settings

pillaiharish/file-upload-server-golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go File Upload Server

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.

Features

  • 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

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

You need to have Go installed on your machine. To install Go, follow the instructions on the official Go website.

Installing

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

Running load tests

cd tests
go run load_test.go

Running vegeta

cd tests/vegeta
./attack.sh

Install vegeta

go install github.com/tsenart/vegeta@latest

Install Gnuplot:

  • On macOS: brew install gnuplot
  • On Linux: sudo apt-get install gnuplot
  • On Windows: Download and install from the official website.

Run the Attack and Plot the Data:

chmod +x tests/vegeta/attack.sh
./tests/vegeta/attack.sh &
gnuplot -persist tests/vegeta/plot.gp

Cleanup:

After you're done, you might want to remove the named pip

rm /tmp/results.bin

Screeshot for mobile browser

Screeshot for mobile browser

About

Clone this repository to enable multi-device file uploads to a web app on a laptop over Wi-Fi using HTTP.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published