This is a Golang http application for uploading and downloading files. It uses AWS S3 for file storage and sqlite3 as a database
- Go 1.21 or higher
- Goose SQL database migration tool (https://github.com/pressly/goose)
- GNU Make (https://www.gnu.org/software/make/)
- An AWS account, user credentials and an S3 Bucket that is configured for public read.
- Clone the repository:
git clone https://github.com/0xdod/fileserve.git
- Change to the project directory:
cd fileserve
- Install dependencies:
go mod download
- Run migrations:
make up-migrate
- Set the environment variables:
cp .env.sample .env
. Remember to set valid S3 credentials - Start the server:
make run
- Open your browser and navigate to
http://localhost:7000
to access the application.
- URL:
/api/v1/files/upload
- Method: POST
- Request Body: Multipart Form data with a file field named
file
- Response: JSON object with the uploaded file details
- URL:
/api/v1/files
- Method: GET
- Response: JSON array containing the list of uploaded files
- URL:
/download/{fileId}
- Method: GET
- Response: The file will be downloaded
To run the unit tests, use the following command:
go test ./...