You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to add a method to retrieve the content of a File object
I think @tbellembois was referring to dom.File which is currently documented as:
File represents files as can be obtained from file choosers or drag and drop. The dom package does not define any methods on File nor does it provide access to the blob or a way to read it.
A File object is specific kind of a Blob, and can be used in any context that a Blob can. In particular, FileReader, URL.createObjectURL(), createImageBitmap(), and XMLHttpRequest.send() accept both Blobs and Files.
Thanks.
The xhr.NewRequest(...) works. I have not tried the second one yet.
I had to change few lines in the server side code from file, _, err := r.FormFile("importFile") to file, err := ioutil.ReadAll(r.Body) to process the file.
Activity
dominikh commentedon May 19, 2016
/cc @shurcooL because I have no idea what the actual API is and what we should add, if anything.
dmitshur commentedon May 21, 2016
You should be able to do this already... mostly.
I think @tbellembois was referring to
dom.Filewhich is currently documented as:From https://developer.mozilla.org/en-US/docs/Web/API/File:
So, you should be able to do:
If you'd like to use
net/httppackage to send the contents offile, you will need to useFileReaderwhichdomdoes not currently cover. /cc @dominikhtbellembois commentedon May 23, 2016
Thanks.
The
xhr.NewRequest(...)works. I have not tried the second one yet.I had to change few lines in the server side code from
file, _, err := r.FormFile("importFile")tofile, err := ioutil.ReadAll(r.Body)to process the file.Many thanks for your quick reply.