dyreschlock / schlock-website

Personal Website code to be run locally or generate a static website hosted through github pages.
http://theschlock.com/
0 stars 0 forks source link

Host Images through Google Drive #47

Closed dyreschlock closed 1 year ago

dyreschlock commented 1 year ago

As I've been making the website more static to be easily hosted ( #46 ), images are a bit of problem. Overall, I have 5gb worth of images for my site, and github has a limit of 5gb for its repositories. But, besides that, these images are already being hosted through Google Drive, so I should be using that storage rather than github.

Google Drive has a unique ID for each file, so it's not a simple process of using the filepath to find the photo.

  1. Figure out some kind of API call to get the unique ID for every image in the photo, image, misc, and spamm directory.
  2. All of the images that we want hosted must be marked visible to anyone.
  3. Cache all these IDs in the database.
  4. When generating pages, replace each IMG link with the link to the image in Google Drive.

The Google Image link should be something like this: https://drive.google.com/uc?id=DRIVE_FILE_ID https://drive.google.com/file/d/13XE4Ah1aK5kSGniMbeard9DJ1iuroR_K/view

dyreschlock commented 1 year ago

This will be a 3-step process. The first 2 steps can be run from a standalone app, and probably also triggers from page loads. The last step happens during page loads.

Actually, once everything has been set in the database, we probably don't need the standalone app anymore as those images and IDs could be created and fetched during the first page load.

dyreschlock commented 1 year ago

Images from the gallery and cover images now use the Image object in the database. The bodyText image links yet do not.

dyreschlock commented 1 year ago

All images that are displayed through the post body, gallery, and as a cover image have objects in the database and when those links are rendered it is looking at these objects. If the object has a google id, it'll use that for its image link. If the object doesn't have a google id, then it'll default to normal links.

dyreschlock commented 1 year ago

The only thing that remains is (1) getting the google id for every image in the database, and (2) making sure those image in drive are set to visible.

dyreschlock commented 1 year ago

This quick start guide from Google worked. I'm able to establish a connection now: https://developers.google.com/drive/api/quickstart/java

dyreschlock commented 1 year ago

Seems like setting the root directory to 'visible' makes everything within visible too!

It would probably be better to do this on an individual file basis, but I think it's good enough :D