是否可以使用客户端生成的blob网址保存到Google云端硬盘 [英] Is it possible to use client-side generated blob url to save to Google Drive

查看:175
本文介绍了是否可以使用客户端生成的blob网址保存到Google云端硬盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在生成CSV客户端并将其放入Blob中,然后创建对象URL。

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

我正在尝试完成的是生成此blob URL,然后将文件保存到Google云端硬盘。我在这个例子中使用了Save to Drive按钮,但它似乎甚至没有加载保存按钮,除非我剥离blob:http:,在这种情况下它会看起来正确加载按钮但这不是一个有效的文件。

What I'm attempting to accomplish is generate this blob URL and then save the file to Google Drive. I'm using the Save to Drive button in this example but it doesn't seem to even load the save button unless I strip off "blob:http:" in which case it will look to load the button correctly but this isn't a valid file anymore.

这甚至可以将blob文件保存到Google云端硬盘吗?

Is this even possible to save a blob file to Google Drive?

以下是我的代码:

    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'
    });

谢谢!

推荐答案

不支持数据URI。请参阅此处:
https://developers.google.com/drive/web/ savetodrive#customizing_savetodrive_tag_attributes

Data URIs are not supported. See here: https://developers.google.com/drive/web/savetodrive#customizing_savetodrive_tag_attributes

这篇关于是否可以使用客户端生成的blob网址保存到Google云端硬盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆