Is it possible to use client-side generated blob url to save to Google Drive

后端 未结 3 626
遥遥无期
遥遥无期 2021-01-15 05:04

I\'m generating a CSV client-side and putting it into a Blob and then creating an object URL.

What I\'m attempting to accomplish is generate this blob URL and then

3条回答
  •  无人共我
    2021-01-15 05:35

    var data = [["one", "info 1", "additional 1"], ["two", "info 2", "additional 2"]],
        csvContent = [], output, objectURL;
    
    data.forEach(function(infoArray, index) {
        var dataString = infoArray.join(",");
        csvContent += index < infoArray.length ? dataString+ "\n" : dataString;
    });
    
    output = new Blob([csvContent], { type: 'text/csv' });
    objectURL = URL.createObjectURL(output);
    
    gapi.savetodrive.render('savetodrive-div', {
      src: objectURL,
      filename: 'save-to-drive.csv',
      sitename: 'Example'
    });
    

    Is this what you need? Credit: http://qaru.site/questions/4397835/is-it-possible-to-use-client-side-generated-blob-url-to-save-to-google-drive

提交回复
热议问题