HttpFilesend

package module
v0.0.0-...-21e1b91 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

README

HttpFilesend

Send and receive Files and Directories via http

Usage:

Sending files:

You can send files by using

resp, err := HttpFilesend.SendFiles("http://example.com", "PATH_TO_YOUR FILE", "PATH_TO_ANOTHER_FILE")

You can send as many files as you want.

Sending directories:

You can send directories by using

resp, err := HttpFilesend.SendDir("http://example.com", "PATH_TO_YOUR_DIRECTORY", "PATH_TO_ANOTHER_DIRECTORY")

You can send as many directories as you want.

Receiving files and directories:

To receive files and directories you have to use the standard http-Library to create a server that receives the request.

First make sure that a certain request ist linked to a http.HandlerFunc

Receiving files:

func ReceiveFiles(w http.ResponseWriter, r *http.Request, dest string) error

Example:
http.HandleFunc("/upload", func(w http.ResponseWrite, r *http.Request) {

    err:=HttpFilesend.ReceiveFiles(w, r, "/YOUR_DESTINATION_FOLDER")
    if err != nil {
        log.Fatal(err)
    }
})
Receiving directories:

func ReceiveDir(w http.ResponseWriter, r *http.Request, dest string) error

Example:
http.HandleFunc("/upload", func(w http.ResponseWrite, r *http.Request) {

    err:=HttpFilesend.ReceiveDir(w, r, "/YOUR_DESTINATION_FOLDER")
    if err != nil {
        log.Fatal(err)
    }
})

Received files and directories will be saved to YOUR_DESTINATION_FOLDER

Documentation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL