Fetch file information for publicly shared Google Drive items.
$ npm install gdrive-file-info
Extends Error
Custom error class used for wrapping HTTP errors
reason
Error original HTTP error
Type: Object
disposition
String Google Drive scan statusfileName
String item filenamedownloadUrl
String generated direct download urlscanResult
String Google Drive scan resultsizeBytes
Number file sizethumbnailUrl
function (Dimensions): Promise<String>
Type: Object
Fetch file info for given item id
input
String Google Drive item view/open url or item id
// fetch public video info
const info = await fetchInfo('https://drive.google.com/open?id=1ObJEVgO6Y4cFjfxszUb1LhdyeKrq_wGD');
console.log(info.downloadUrl);
//=> https://doc-00-6c-docs.googleusercontent.com/docs/securesc/…/1ObJEVgO6Y4cFjfxszUb1LhdyeKrq_wGD
// generate poster url
const thumbnailUrl = await info.thumbnailUrl({ width: 1280, height: 720 });
//=> https://lh3.googleusercontent.com/9CwZKAQJ2U0CjjcIt5iZCqd-w-0d5ClJuYHVlS4olLrzt6AZr9rCdDu4jVzrz9b-tK5aswE4vdA=w1280-h720-p
- Throws GDriveError throws on querying missing/private items
- Throws TypeError throws on invalid ID provided
Returns Promise<FileInfo> item info
Extract item id from Google Drive shareable link
url
String Google Drive item view/open url
// with _open_ link
const id = getItemId('https://drive.google.com/open?id=1ObJEVgO6Y4cFjfxszUb1LhdyeKrq_wGD');
//=> 1ObJEVgO6Y4cFjfxszUb1LhdyeKrq_wGD
// with _view_ link
const id = getItemId('https://drive.google.com/file/d/1ObJEVgO6Y4cFjfxszUb1LhdyeKrq_wGD/view?usp=sharing');
//=> 1ObJEVgO6Y4cFjfxszUb1LhdyeKrq_wGD
// with _edit_ link
const id = getItemId('https://docs.google.com/document/d/1OHA32KWVF21s0ahDMr8Qv2oDamQuLNoYkTN0N_RuRXA/edit');
// => 1OHA32KWVF21s0ahDMr8Qv2oDamQuLNoYkTN0N_RuRXA
Returns String item id