Getting a file from a record in Go #4458
-
Hey folks, Working on an app using Pocketbase as a framework. I need to get a field on a record, "file", as either a file or its bytes. How do I access file fields on records? I don't necessarily need an end-to-end example, but maybe something added to this page might help? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
ganigeorgiev
Feb 29, 2024
Replies: 2 comments 2 replies
-
The record file operations will be simplified and documented better in the future, but for now here is one minimal example: key := record.BaseFilesPath() + "/" + record.GetString("yourFileField")
fsys, _ := app.NewFilesystem()
defer fsys.Close()
blob, _ := fsys.GetFile(key)
defer blob.Close()
// do something with the blob reader... |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
ndarilek
-
Oh very helpful, thanks!
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The record file operations will be simplified and documented better in the future, but for now here is one minimal example: