问题
i was trying to send word document from one user to another using peer.js it is fine working with text file (.txt, text/plain) where ever on word document i'm not getting content.
here is what i did till now
box.on('drop', function (e) {
e.originalEvent.preventDefault();
var file = e.originalEvent.dataTransfer.files[0];
eachActiveConnection(function (c, $c) {
if (c.label === 'file') {
if (file.type == "text/plain") {
alert("type : " + file.type + " - sendable");
c.send(file);
} else {
//here i need to convert word document into text/plain or atleast to string and send the file by using // c.send(file)
}
回答1:
I'm not an expert, but AFAIK docx documents follow a standard which is not simple plain text (as RTF is). I'd give a chance to DOCX.js, which promises to transform docx base64 strings back and forth to HTML.
来源:https://stackoverflow.com/questions/31181381/on-ondrop-event-convert-word-document-to-text-or-string-using-javascript