0

I would like to convert a sharepoint document file to a base 64 format by using File reader. But the problem is that when I fetch the sharepoint document by Get_file (). It returns the file in sp.File object. But to use it in Filereader I need it to be either F ile object or Blob. Any help or pointers appriciated

After getting the itemd from the sharepoint document i use this code to call filereader and get a type mismatch error. I get the sharepoint Item from document library and then use this:

function(items){
    for(var i = 0; i < items.get_count();i++) {
        var file = items.get_item(i).get_file();
        alert(file);
        var reader = new FileReader();
        reader.readAsDataURL(file);
        //rest of my code
    }
}
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
S.Ban
  • 1
  • 1
  • 3
    Please help the community help you by providing the code you are using! – RedBassett Feb 06 '17 at 10:34
  • After getting the itemd from the sharepoint document i use this code to call filereader and get a typemissmatch error function(items){ for(var i = 0; i < items.get_count();i++) { var file = items.get_item(i).get_file(); alert(file); var reader = new FileReader(); reader.readAsDataURL(file); ---rest of my code} – S.Ban Feb 06 '17 at 10:41
  • Its not returning a file contents, just its metadata. Try this one http://stackoverflow.com/questions/37322986/read-content-of-sp-file-object-as-text-using-jsom – Alex K Feb 15 '17 at 15:40

0 Answers0