MCPcopy
hub / github.com/pocketbase/pocketbase / BindFilesystem

Function BindFilesystem

plugins/jsvm/binds.go:756–775  ·  view source on GitHub ↗

BindFilesystem registers $filesystem.* namespaced object with common filesystem package related helpers. See https://pocketbase.io/jsvm/modules/_filesystem.html.

(vm *goja.Runtime)

Source from the content-addressed store, hash-verified

754//
755// See https://pocketbase.io/jsvm/modules/_filesystem.html.
756func BindFilesystem(vm *goja.Runtime) {
757 obj := vm.NewObject()
758 vm.Set("$filesystem", obj)
759
760 obj.Set("s3", filesystem.NewS3)
761 obj.Set("local", filesystem.NewLocal)
762 obj.Set("fileFromPath", filesystem.NewFileFromPath)
763 obj.Set("fileFromBytes", filesystem.NewFileFromBytes)
764 obj.Set("fileFromMultipart", filesystem.NewFileFromMultipart)
765 obj.Set("fileFromURL", func(url string, secTimeout int) (*filesystem.File, error) {
766 if secTimeout == 0 {
767 secTimeout = 120
768 }
769
770 ctx, cancel := context.WithTimeout(context.Background(), time.Duration(secTimeout)*time.Second)
771 defer cancel()
772
773 return filesystem.NewFileFromURL(ctx, url)
774 })
775}
776
777// BindFilepath registers $filepath.* namespaced object with
778// common std Go filepath package related exports.

Callers 3

TestBindFilesystemFunction · 0.85
registerMigrationsMethod · 0.85
registerHooksMethod · 0.85

Calls 2

NewFileFromURLFunction · 0.92
SetMethod · 0.65

Tested by 1

TestBindFilesystemFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…