Skip to content

stanlee321/file_streaming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Large File Streaming in Go over HTTP

This is a simple Go project that demonstrates how to send and receive files using Go. The project has two modes: CLI and HTTP.

Getting Started

Prerequisites

  • Go (version 1.16 or higher)

Installation

  1. Initialize the Go module:

    go mod init file_handler
  2. Download the dependencies:

    go mod tidy

Running the Project

2. CLI Mode:

  • Flags are used to choose between sending and receiving (mode flag).
  • If the file flag is provided, the program sends the specified file.
  • If no file is specified, the server starts and listens for incoming files.

3. HTTP Mode:

  • The Gin framework is used to handle POST requests at the /upload endpoint.
  • Files are uploaded using multipart form data and saved to the specified directory.

How to Run:

CLI Mode:

  • Start the server to receive files:
    go run main.go --mode cli --save-dir /path/to/save
  • Send a file:
    go run main.go --mode cli --file /path/to/demo.mp4 --address 0.0.0.0:8080

HTTP Mode:

  • Start the HTTP server:
    go run main.go --mode http --save-dir /path/to/save
  • Upload a file via HTTP POST:
    curl -X POST -F "file=@/path/to/demo.mp4" http://0.0.0.0:8080/upload

Building the Project

To build the project, use the following command:

go build -o file_handler main.go

About

Large File Streaming in Go over HTTP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages