MCPcopy Index your code
hub / github.com/ZenNotes/zennotes / uploadAsset

Method uploadAsset

apps/server/internal/httpserver/server.go:899–923  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

897}
898
899func (s *Server) uploadAsset(w http.ResponseWriter, r *http.Request) {
900 cfg := s.currentConfig()
901 r.Body = http.MaxBytesReader(w, r.Body, cfg.MaxAssetBytes+multipartOverheadBytes)
902 if err := r.ParseMultipartForm(8 << 20); err != nil {
903 http.Error(w, err.Error(), http.StatusBadRequest)
904 return
905 }
906 notePath := r.FormValue("notePath")
907 file, header, err := r.FormFile("file")
908 if err != nil {
909 http.Error(w, err.Error(), http.StatusBadRequest)
910 return
911 }
912 defer file.Close()
913 asset, err := s.currentVault().ImportAsset(notePath, header.Filename, file)
914 if err != nil {
915 if errors.Is(err, vault.ErrAssetTooLarge) {
916 http.Error(w, "asset too large", http.StatusRequestEntityTooLarge)
917 return
918 }
919 writeError(w, err)
920 return
921 }
922 writeJSON(w, http.StatusOK, asset)
923}
924
925// --- WebSocket watcher ---
926

Callers

nothing calls this directly

Calls 7

currentConfigMethod · 0.95
currentVaultMethod · 0.95
writeErrorFunction · 0.85
writeJSONFunction · 0.85
ErrorMethod · 0.80
CloseMethod · 0.80
ImportAssetMethod · 0.80

Tested by

no test coverage detected