BindFilesystem registers $filesystem.* namespaced object with common filesystem package related helpers. See https://pocketbase.io/jsvm/modules/_filesystem.html.
(vm *goja.Runtime)
| 754 | // |
| 755 | // See https://pocketbase.io/jsvm/modules/_filesystem.html. |
| 756 | func 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. |
searching dependent graphs…