Skip to content

Conversation

@AndreRenaud
Copy link

I wrote this as a side effect of a separate command line tool I was working on, and it felt like it might be more widely useful.

See https://pkg.go.dev/io/fs for interface details

Example usage:

package main

import (
	"log"
	"net/http"
	"os"

	"github.com/t3rm1n4l/go-mega"
)

var USER string = os.Getenv("MEGA_USER")
var PASSWORD string = os.Getenv("MEGA_PASSWD")

func main() {
	m := mega.New()
	if err := m.Login(USER, PASSWORD); err != nil {
		log.Fatalf("Cannot connect to Mega: %s", err)
	}

	mux := http.NewServeMux()
	mux.Handle("/", http.FileServer(http.FS(m)))

	if err := http.ListenAndServe(":8000", mux); err != nil {
		log.Fatal(err)
	}
}

Then browse to http://localhost:8000 to see the content.

There aren't any tests yet (which there should be), but I thought I'd ask for feedback before cleaning everything up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant