Skip to content

Instantly share code, notes, and snippets.

@samuelkarani
Last active October 21, 2024 05:10
Show Gist options
  • Save samuelkarani/d850971294629298d4a350d3913607dd to your computer and use it in GitHub Desktop.
Save samuelkarani/d850971294629298d4a350d3913607dd to your computer and use it in GitHub Desktop.
export const getThumbnail = (id, size = 300) =>
`https://drive.google.com/thumbnail?id=${id}&sz=${size}`;
export const getIcon = (mimeType) =>
`https://drive-thirdparty.googleusercontent.com/256/type/${mimeType}`;
export const getFile = (id) => `https://drive.google.com/uc?id=${id}`;
const downloadFile = (id) =>
`https://drive.google.com/uc?export=download&id=${id}`;
export const webViewerURL = (url) =>
`https://docs.google.com/viewer?url=${url}`;
export const webViewerID = (id) => `https://drive.google.com/file/d/${id}/view`;
export const webPreviewerID = (id) => `https://drive.google.com/file/d/${id}/preview`;
export const copyDocs = (
id,
copyComments = true,
includeResolvedCommentsOnCopy = true,
copyCollaborators = false,
userstoinvite
) =>
`https://docs.google.com/document/d/${id}/copy?${new URLSearchParams({
copyComments,
includeResolvedCommentsOnCopy,
copyCollaborators,
userstoinvite,
})}`;
// formats: pdf, doc, txt, html, odt, epub
const downloadDocs = (id, format) =>
`https://docs.google.com/document/d/${id}/export?format=${format}`;
// formats: pdf, pptx
const downloadSlides = (id, format) =>
`https://docs.google.com/presentation/d/${id}/export/${format}`;
const downloadSlidesPage = (id, page) =>
`https://docs.google.com/presentation/d/${id}/export/png?pageid=p${page}`;
// formats: pdf, xlsx, csv
const downloadSheets = (id, format) =>
`https://docs.google.com/spreadsheets/d/${id}/export?format=${format}`;
// formats: pdf, svg, jpg
const downloadDrawings = (id, format) =>
`https://docs.google.com/drawings/d/${id}/export/${format}`;
@jpluimers
Copy link

@LazZiya if I understand you correctly, that's the embedded=true& part in https://docs.google.com/viewer?embedded=true&url=[PDF-URL]

@jj449
Copy link

jj449 commented Mar 25, 2024

Very useful , thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment