func main() { // TODO(tsileo): host flag // and display an usage func // api key as a venv // and support an optional namespace as arg // Store the latest uploaded blob as feature? log the uploaded? with an optional comment (import vkv) // and write a README // sharing feature (with a blob app to register?) apiKey := os.Getenv("BLOB_API_KEY") if len(os.Args) < 2 { fmt.Println("Missing hash, use \"-\" to upload from stdin") os.Exit(1) } blobstore := client.NewBlobStore("") blobstore.SetAPIKey(apiKey) if os.Args[1] == "-" { stdin, err := ioutil.ReadAll(os.Stdin) if err != nil { panic(err) } hash := fmt.Sprintf("%x", blake2b.Sum256(stdin)) if err := blobstore.Put(hash, stdin); err != nil { panic(err) } fmt.Printf("%s", hash) os.Exit(0) } blob, err := blobstore.Get(os.Args[1]) if err != nil { panic(err) } fmt.Printf("%s", blob) os.Exit(0) }
func main() { bs = client.NewBlobStore(defaultAddr) kvs = client.NewKvStore(defaultAddr) r := mux.NewRouter() r.HandleFunc("/", indexHandler) r.HandleFunc("/api/notebook", notebooksHandler) r.HandleFunc("/api/note", notesHandler) r.HandleFunc("/api/note/version/{hash}", noteVersionHandler) r.HandleFunc("/api/note/{id}", noteHandler) r.HandleFunc("/api/note/{id}/pdf", pdfHandler) r.HandleFunc("/api/upload/{notebook}", uploadHandler) r.HandleFunc("/api/clip", clipHandler) r.HandleFunc("/_reindex", reindexHandler) http.Handle("/public/", http.StripPrefix("/public", http.FileServer(http.Dir("public")))) http.Handle("/", r) log.Fatalf("%v", http.ListenAndServe(":8055", nil)) }
func New(addr string) *RemoteBackend { return &RemoteBackend{ bs: client.NewBlobStore(addr), addr: addr, } }