简体   繁体   English

是否有可能写入文本文件然后上传到谷歌驱动器反应?

[英]Is it possible to write text file then upload to google drive in react?

i'm trying to write string to text file then upload to google drive is it possible via javascript or using react-google-picker ? 我正在尝试将字符串写入文本文件,然后通过javascript或使用react-google-picker上传到谷歌驱动器?

here's my code to download file to my local storage... 这是我的代码下载文件到我的本地存储...

    Download= () => {
        var _this = this;
        const element = document.createElement("a");
        const file = new Blob([_this.state.xmldata], { type: 'text/plain' });
        element.href = URL.createObjectURL(file);
        element.download = "text.txt";
        document.body.appendChild(element);
        element.click();
    }

Thank you 谢谢

I believe what you're looking for is if google drive has an api that enables you to create a file. 我相信你要找的是google驱动器是否有api,可以让你创建一个文件。 This isn't really react specific. 这不是特定的反应。

I believe you'll find the 3rd link to be the most useful. 我相信你会发现第三个链接是最有用的。 Essentially, you just need to post the file to their rest api with your authentication: 基本上,您只需要使用您的身份验证将文件发布到其余的api:

POST https://www.googleapis.com/upload/drive/v3/files

Here is the full API Documentation: https://developers.google.com/drive/api/v3/reference/ 以下是完整的API文档: https//developers.google.com/drive/api/v3/reference/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM