Skip to content

Commit 41d4183

Browse files
committed
2 parents ac509b1 + 5ddef30 commit 41d4183

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/windows8/FileProxy.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,47 @@ module.exports = {
191191
);
192192
},
193193

194+
readAsBinaryString:function(win,fail,args) {
195+
var fileName = args[0];
196+
197+
198+
Windows.Storage.StorageFile.getFileFromPathAsync(fileName).then(
199+
function (storageFile) {
200+
Windows.Storage.FileIO.readBufferAsync(storageFile).done(
201+
function (buffer) {
202+
var dataReader = Windows.Storage.Streams.DataReader.fromBuffer(buffer);
203+
var fileContent = dataReader.readString(buffer.length);
204+
dataReader.close();
205+
win(fileContent);
206+
}
207+
);
208+
}, function () {
209+
fail && fail(FileError.NOT_FOUND_ERR);
210+
}
211+
);
212+
},
213+
214+
readAsArrayBuffer:function(win,fail,args) {
215+
var fileName = args[0];
216+
217+
218+
Windows.Storage.StorageFile.getFileFromPathAsync(fileName).then(
219+
function (storageFile) {
220+
var blob = MSApp.createFileFromStorageFile(storageFile);
221+
var url = URL.createObjectURL(blob, { oneTimeOnly: true });
222+
var xhr = new XMLHttpRequest();
223+
xhr.open("GET", url, true);
224+
xhr.responseType = 'arraybuffer';
225+
xhr.onload = function() {
226+
win(xhr.response);
227+
};
228+
xhr.send();
229+
}, function () {
230+
fail && fail(FileError.NOT_FOUND_ERR);
231+
}
232+
);
233+
},
234+
194235
getDirectory:function(win,fail,args) {
195236
var fullPath = args[0];
196237
var path = args[1];

0 commit comments

Comments
 (0)