NewFileFromPath creates a new File instance from the provided local file path.
(path string)
| 45 | |
| 46 | // NewFileFromPath creates a new File instance from the provided local file path. |
| 47 | func 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. |
| 64 | func NewFileFromBytes(b []byte, name string) (*File, error) { |
searching dependent graphs…