简体   繁体   中英

Javascript upload file from web page to specific google drive account

I'm developing an web application right now.

What I have so far in the app is this:

<input type="text" id="textToSendToMyGoogleDrive"/>
<button id="upload file to google drive"> Send </button>

This application has a domain, so every one can go to this application from their computer.

What I want to do is when any user put text in the input, and clicks the button, it will make a txt file and send it into my google drive account.

So I have two problems here:

  1. How to take the text and make from it a txt file.

  2. Send the file to specific google drive account.

Problem number 2 is a problem because I have looked every where in the google drive API, and all I could found is some methods to upload files to the user's google drive, and not to mine. So I tried to search out how to "sign in" the user when he is in the application to my google drive, and I could not find a solution.

If I was not clear on the problems, comment me.

Thank you!

I'am not a expert but correct me if I'am wrong. I think there is a problem with your approach. how about sending your text content as a request parameter to the backend and save it as a .txt from there.

I am suggesting this because, let say you save your file with text content in users computer as described in here .

next step would be to access it from the browser and save it in the google drive. if you planning to do it from the front end without a backend, you have to expose your google credentials to every user.

Before that you wont be able to access a local file from users computer directly from the browser. because most browsers wont allow you to do that. so please change your approach to this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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