-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
file:///tmp/browser.1293014077.html ERR_FILE_NOT_FOUND #46
Comments
The following example worked on macOS. If it worked for you too, you may have placed the files in an insecure directory. package main
import (
"log"
"os"
"path/filepath"
"github.com/pkg/browser"
)
func main() {
pathDirTmp, err := os.MkdirTemp(os.TempDir(), "sample_dir_*")
if err != nil {
log.Fatal(err)
}
pathFileTmp := filepath.Join(pathDirTmp, "sample_file.html")
dummyContent := `<html><body>Hello World2</body></html>`
// Create file under the temporary directory
if err := os.WriteFile(pathFileTmp, []byte(dummyContent), 0644); err != nil {
log.Fatal(err)
}
// Open the file in the browser
// if err := browser.OpenURL(pathFileTmp); err != nil {
// log.Fatal(err)
// }
// Open the file for reading
osFile, err := os.Open(pathFileTmp)
if err != nil {
log.Fatal(err)
}
// Consume the contents and present the results in a browser
if err := browser.OpenReader(osFile); err != nil {
log.Fatal(err)
}
// Open the directory of the temporary file
if err := browser.OpenURL(pathDirTmp); err != nil {
log.Fatal(err)
}
} Env info
|
You said "you may have placed the files in an insecure directory" But I am using it like this:
This means, that I am not explicitly putting the content into a directory.... I had a look at how this gets handled by Python, but that's a huge file: https://github.com/python/cpython/blob/3.10/Lib/webbrowser.py Sorry, I need to leave now. Feel free to close this, if you don't have time and energy. |
Yes yes, that's why the file pointer is passed like this.
My point was that "Where was the temp file created?" The path "
The Try using
Unfortunately, I'm only a passer-by to help and don't have the privilege to close this issue. |
I use it like this:
The file
/tmp/browser.1293014077.html
contains the html.But the browser seems to not find the file.
I use Chromium on Ubuntu Linux
The text was updated successfully, but these errors were encountered: