Use Google Drive as a PDF file server for my Website - html

I am building a simple public website that will allow users to search and view various PDF files. I plan to store the PDF files on a public folder in my Google Drive. The link to my test folder is:
https://drive.google.com/open?id=1pBTWzuElA-gSLPvQAHlnonamfon6V1NW
In this folder there are 2 PDF files - File1.PDF and File2.PDF
I would like to be able to link to these from an HTML page but have no idea how to do it - I have searched this forum but with no luck so far - the closest I have found is how to download files from gdrive via a local program rather than a public website

Drive has its own api that you could use here
Hope this help

Related

preview html files in google drive without making them public

I have a bunch of html files in my drive and I want to be able to preview them without downloading them to local. I also don't want to create a public folder and store them there. Basically I want the files to be only visible to me and to people whom I share with. Is it possible?
I don't have to necessarily view the pages in the drive.google.com, it's ok to be a url which has to be accessed outside of drive.google.com, and I can bookmark that url to visit the html files and send the link to authorized people.
I came across this solution in SO but it suggests to create a public folder.
opening html from google drive

Downloading files from Drive using alt=media with correct filename

I'm having trouble allowing files (non-shared) to be downloaded from a Google Drive account. I've created a listing using the php drive sdk and would like to provide authorised links to download the files using a generated access token. I've got downloads working with links like this:
https://www.googleapis.com/drive/v3/files/[fileid]?alt=media&access_token=[access_token]
The problem is that whenever a file is downloaded, it is named [fileid].[extension], rather than the real file name that appears in Drive.
I've tried adding the download="[real filename]" into the a link to suggest the correct filename, but it's being ignored in all the browsers I've tried.
I've got an alternative working that gets the file piece by piece server side and echoes it out as a file via php, but I'd prefer for downloads to be straight from Drive to the user.

How to save my data in a cloud?

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.

Google Drive web hosting: deny directory listing

I had my website hosted on a Google Drive public folder based on the following post: http://googleappsdeveloper.blogspot.com/2012/11/announcing-google-drive-site-publishing.html
Sample website:
https://googledrive.com/host/0B716ywBKT84AcHZfMWgtNk5aeXM
Now the problem is a link to the root folder displays all the files on my public folder. I know I can prevent it by adding an index.html file to my public folder to replace the listing, but my folder contents are still accessible through the following URL:
https://drive.google.com/folderview?id=FOLDER-ID&usp=sharing
You can even access them by signing in to your own Google account and navigating to the following page:
https://drive.google.com/#folders/FOLDER-ID
In comparison, on a public folder/subfolder on Dropbox each individual file is publicly available, but the root directory listing is denied.
Examples:
Folder: https://dl.dropboxusercontent.com/u/4017788/logo.png
Subfolder: https://dl.dropboxusercontent.com/u/4017788/Labs/image1.jpg
How can I achieve the same functionality on a Google Drive public folder?
Thanks!
The ACL semantics of Drive is quite different than Dropbox's sharing. In order to make a folder publishable you need to at least give read access to public, meaning once your directory ID is known, it could be listed via the front-end and the API.
In the longer term, we can restrict the listings by not listing children files shared with public but only with those who knows the link.

Generate a URL for Google Drive publicly shared files and access them

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.