MCPcopy
hub / github.com/pocketbase/pocketbase / NewFileFromPath

Function NewFileFromPath

tools/filesystem/file.go:47–61  ·  view source on GitHub ↗

NewFileFromPath creates a new File instance from the provided local file path.

(path string)

Source from the content-addressed store, hash-verified

45
46// NewFileFromPath creates a new File instance from the provided local file path.
47func NewFileFromPath(path string) (*File, error) {
48 f := &File{}
49
50 info, err := os.Stat(path)
51 if err != nil {
52 return nil, err
53 }
54
55 f.Reader = &PathReader{Path: path}
56 f.Size = info.Size()
57 f.OriginalName = info.Name()
58 f.Name = normalizeName(f.Reader, f.OriginalName)
59
60 return f, nil
61}
62
63// NewFileFromBytes creates a new File instance from the provided byte slice.
64func NewFileFromBytes(b []byte, name string) (*File, error) {

Callers 3

TestFileSystemUploadFileFunction · 0.92
TestNewFileFromPathFunction · 0.92
CreateBackupMethod · 0.92

Calls 2

normalizeNameFunction · 0.85
SizeMethod · 0.80

Tested by 2

TestFileSystemUploadFileFunction · 0.74
TestNewFileFromPathFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…