How can I save api request response directly to google drive ?
Example :
If I pull a csv report from a reporting API, now I need the file to be directly downloaded into my google drive instead of getting downloaded locally onto my system.
You can use the Save to Drive Button.
The Save to Drive button enables your web site to allow users to save
files to their Drive account from an arbitrary URL via their browser.
The button is configured with a few attributes in a div tag in the
HTML markup, similar to how the +1 button is created.
Snippet of code from the documentation:
The simplest way to display a Save to Drive button on your page is to
include the necessary JavaScript resource and to add the Save to Drive
button tag:
<script src="https://apis.google.com/js/platform.js" async defer></script>
<div class="g-savetodrive"
data-src="//example.com/path/to/myfile.pdf"
data-filename="My Statement.pdf"
data-sitename="My Company Name">
</div>
This is how it works:
The technology used to upload files is similar to that used by the
Google Drive web user interface. The file is downloaded to the user's
browser in parts and uploaded to Google Drive as data is received.
This allows the user to save files that require some form of HTTP
authentication because the download is made in the context of the
user's browser.
If the user navigates away from the page before the download is
complete, the data is discarded and no file is created.
Related
I am creating pdfs and sending them to a directory located in my website files. when these new files are created I want to automatically send them to google drive the user should not have to press any buttons. I have the google drive api set up and working with php using this github example, but do not know what to do next this is the last piece to having my site complete. Thanks for all advice.
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:
How to take the text and make from it a txt file.
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.
I would like to create a website which enables users to save a web file to their Google Drive Account. User has to paste the URL of the file and upon submitting the file will be saved to user's Google Drive account. This website offers such a functionality (not necessarily from Picker API). I would like to replicate it. How it could be done?
Not necessarily the Google Picker API but you may want to try the Save to Drive Button feature of Google Drive API. This feature enables your web site to allow users to save files to their Drive account from an arbitrary URL via their browser. The button is configured with a few attributes in a div tag in the HTML markup, similar to how the +1 button is created.
The simplest way to display a Save to Drive button on your page is to include the necessary JavaScript resource and to add the Save to Drive button tag:
<script src="https://apis.google.com/js/platform.js" async defer></script>
<div class="g-savetodrive"
data-src="//example.com/path/to/myfile.pdf"
data-filename="My Statement.pdf"
data-sitename="My Company Name">
</div>
For more detailed information and examples, please try going through the given link.
Hope that helps! Cheers!
I am trying to build an application which will implement following functionalities
It will displays the filenames in my google drive account
Each file has a Delete File button that can delete the file from my google drive account
Page has a Add File button that lets me upload a new file to my google drive account
Each file has a View File button. If the file is a PDF, display the PDF file in the browser using any open js library of your choice. If the file is not a PDF, download the file to the computer.
Please suggest code or any link or api.
It's all possible with Google Drive REST API. It is well documented and there is a lot of guides and wide variety of languages you can use.
I think the most appreciate for you will be JavaScript. Link to JS quickstart
On http://www.html5rocks.com/en/tutorials/file/dndfiles/ it says:
As example of its capabilities, the File API could be used to create a thumbnail preview of images as they're being sent to the server, or allow an app to save a file reference while the user is offline.
I cannot find any information about how it works to save a file reference while the user is offline. Is there a possibility to solve this problem? Where can I find information about it?