-
Notifications
You must be signed in to change notification settings - Fork 570
How to build on Windows; how to get contents of a file from <input type="file"> as a []byte? #776
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
Comments
I don’t think any of GopherJS developers use or support Windows, so building with |
Thank you so much, it works pretty nice. Even features that is not mentioned in the page of compatibilities. I have one question, I think it's the last one, I don't know if I need to open one new issue. But, It's possible to get data from one |
Yes, that is absolutely possible. The See https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement and https://developer.mozilla.org/en-US/docs/Web/API/FileList. In the |
I'll take a look in the first alternative, that uses the Javascript. I'm trying with
In the docs it says "The dom package does not define any methods on File nor does it provide access to the blob or a way to read it.". :\ |
I found one similar issue, dominikh/go-js-dom#32. I don't know if have a better method, if something change in the GopherJS since this issue. But for now I'm using something based in your code, in the reply. 👍
If someone have the same problem, but will be nice if the |
Indeed. You need to do it yourself with something like: // blobToBytes converts a Blob to []byte.
func blobToBytes(blob *js.Object) []byte {
b := make(chan []byte)
fileReader := js.Global.Get("FileReader").New()
fileReader.Set("onload", func() {
b <- js.Global.Get("Uint8Array").New(fileReader.Get("result")).Interface().([]byte)
})
fileReader.Call("readAsArrayBuffer", blob)
return <-b
} Edit: You beat me to it. 👍 |
Add instructions for what people should do when building with GopherJS on unsupported platforms. Code generation works completely fine, but syscalls (e.g., for gopherjs run) will only work on supported platforms. Previously, this information was only in issues, people's heads, commit messages, etc. It should be documented in README to provide clarity. Rename "OS X" to "macOS", the current name of that operating system. Rearrange sections to place more relevant information first. Mention Linux before macOS consistently. Linux is placed first because it's open source and more freely available than the proprietary macOS, so it's easier to recommend it as an alternative. Resolves #770. Updates #776. Updates #688.
Add instructions for what people should do when building with GopherJS on unsupported platforms. Code generation works completely fine, but syscalls (e.g., for gopherjs run) will only work on supported platforms. Previously, this information was only in issues, people's heads, commit messages, etc. It should be documented in README to provide clarity. Rename "OS X" to "macOS", the current name of that operating system. Rearrange sections to place more relevant information first. Mention Linux before macOS consistently. Linux is placed first because it's open source and more freely available than the proprietary macOS, so it's easier to recommend it as an alternative. Resolves #770. Updates #776. Updates #688.
That doesn't seem to work on Windows, but then again, I'm manually inputting it into the commandline + batch file. |
@Azareal |
I'm using Windows and go1.10. I'm trying to build (
gopherjs build
) this code:The text was updated successfully, but these errors were encountered: