I want to know if there is any way to implement so that users can upload files on my website from their Google Drive account. I need to collect users school assignments, and right now I need them to export their Google Documents to PDF and then upload them. This requires an extra step, and I wonder if you can put a button instead on my website that says something like "Upload file from Google Drive", and they can click on it and choose which document to upload.
Use https://developers.google.com/drive/v2/web/picker to allow the user to choose the file. The picker returns a file ID, which you can then use with the Drive SDK to fetch the contents and ulpoad to your own server.
Related
I know it is possible to get a link that will initiate a download of a file from Google Drive. But this is not exactly what I am looking for. I want to be able to have the link of a file with its extension.
For example, it is possible to do this with Dropbox. I am able to get a direct link if I change "www.dropbox.com" to "dl.dropboxusercontent.com". So if I have a video file, it will play on the browser's player instead of opening the page to download it.
With Google Drive I don't know how to do this. If I generate a direct link, it will then create a link that automatically starts a download. A direct link for a .txt file will not be rendered on the browser. It will be downloaded instead.
So, it is possible to have a direct link to a file in Google Drive that is not the direct link that starts downloading automatically, but instead with the directory/file.ext?
There are several things you need to understand about how the Google drive api works.
When you do a file.get with the Google Drive api it returns a file resource this is the response for the file itself. The information about it that google is willing to share with us. There are two fields here you may find interesting
The first thing you should know is that a file has one or the other of these links not both. If the file is a binary type for example an image you will be given a webContentLink which can be used to download the file, If its say a google sheet then you will be given a webViewLink which can be used to view the file in Google Drive web application.
Which link you get depends entirely upon the type of file it is. No matter which link you get you will still need to have permission to access this file. So whoever clicks the link must have at the very least read permission to the file.
On the Google drive web application we can create links which can be shared with anyone and allow anyone to "access" there is no way to create these links VIA the api.
What you wish to do is out of scope for the Google drive api, probably due to security reasons. Also the simple fact that google drive api is not a file service api it a file storage system. THere is a difference.
hi i am working on project in which requirement is i have to upload images on some cloud services like google drive or other, and it generates a URL of images like http://example.com/images/1.jpg etc and share this URL with any one.
I already tried this method (but it not fulfill my requirement) :
How do I display images from Google Drive on a website?
If you have some image files, just upload them to a public folder on
your Google Drive, copy its folder ID from the address bar (e.g.
0B0Gi4v5omoZUVXhCT2kta1l0ZG8) and paste it into a form at GDrives,
then choose your own alias (e.g. myimgs) and voila! You can access the
images one by one using e.g.
http://gdriv.es/myimgs/myimage.jpg
If you want to embed a whole folder on your website (in a frame), you can use one of the following URLs, replacing [folderID] with your
own ID:
http://gdriv.es/myimgs/
https://docs.google.com/folder/d/[folderID]/preview?rm=minimal
https://drive.google.com/folderview?id=[folderID]
If you prefer to get the file list in XML or JSON, you can use YQL.
Note: You can use Google+ Photos to host ans embed your images as well.
I don't know if this is possible, but I would like to save some data of my website, like images and documents in a cloud like dropbox or google drive and I want that these data are available and visible to someone looking my site.
is it possible? (My intention is to continue storing the html,js etc data on the server)
You can do that with Dropbox or Google Drive.
For Dropbox, put your all images to a folder and make this folder public. Then, right click the image or js file and select the copy public link. You can use this link for your images or js files.
I have a collection of PDF files on a Google Drive. I have shared them and I want to be able to link to them from a list on a web site. What I'd like to be able to do is work out the file name of the PDF using information in the list. As a simple example, if my list contains items 1, 2 and 3 I'd like to be able to upload PDF files 1.PDF 2.PDF and 3.PDF to Google Drive then have the web site just link to those when a link is clicked and show the PDF files in the browser.
So, I guess I could do this just by uploading the PDF to Google Drive and manually adding a link to PDF on the web site. However, what I want to do is generate the link programmatically so that when I have, say, 50 PDF files I don't have to keep getting the link from Google Drive and adding it to the web site. The site should just work out that item 50, say, in the list will link to 50.PDF, for example.
I've tried to get the file id using the API but that requires the authorization token to be generated and manual intervention to take place, so that won't work. At least, not at the point where the file is viewed because the viewer is anonymous.
So my questions are:
Is it possible to work out what a file name will be on the drive using just something like an item number in a list?
I guess that there are maybe some other options - for example, when I add the items to the list on the web site programmatically, I could go and locate the google drive file manually using a web application and link it using the file id at that point. I could store the ID in a database - however, would any anonymous user then be able to just click on the file link on the web site and view the file?
Finally, can anyone think of another way to do this?
Any help would be appreciated! :)
Is it possible for you to use a service account? You can authorize the app with an account dedicated to your app and user doesn't need to authorize and authenticate. The files you will be uploading will be managed under the service account's Drive.
You can learn more about service accounts on https://developers.google.com/accounts/docs/OAuth2ServiceAccount
If you have implementation specific questions, please ask.
Can a google drive application generate a preview for a file (which is not handled by google drive by default) when a file of that type is uploaded by the user, rather than creating it using that application?(Assuming the user has authorized that application)
Unfortunately, no, sorry.
The closest we have is being able to generate a third party thumbnail for a file. Your app can decide how the file will appear in the Google Drive thumbnail view by uploading the necessary image(s).
The video here explains it: http://www.youtube.com/watch?v=jG5-9zlaPL8