
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
browser-ts-google-drive
Advanced tools
Manage google drive easily. Support create folders, upload files, download files, searching, etc..
Manage Google Drive easily. Support create folders, upload files, download files, searching, etc.. The library is build with Google Drive API v3.
import {TsGoogleDrive} from "ts-google-drive";
import {google} from "googleapis";
const tsGoogleDrive = new TsGoogleDrive({keyFilename: "serviceAccount.json"});
async function auth() {
const drive1 = new TsGoogleDrive({keyFilename: "serviceAccount.json"});
const drive2 = new TsGoogleDrive({credentials: {client_email: "", private_key: ""}});
// https://www.npmjs.com/package/google-auth-library
const drive3 = new TsGoogleDrive({oAuthCredentials: {access_token: ""}});
const drive4 = new TsGoogleDrive({oAuthCredentials: {refresh_token: ""}, oauthClientOptions: {clientId: "", clientSecret: ""}});
}
async function getSingleFile() {
const fileId = "";
const file = await tsGoogleDrive.getFile(fileId);
if (file) {
const isFolder = file.isFolder;
}
}
async function listFolders() {
const folderId = "";
const folders = await tsGoogleDrive
.query()
.setFolderOnly()
.inFolder(folderId)
.run();
}
async function createFolder() {
const folderId = "";
const newFolder = await tsGoogleDrive.createFolder({
name: "testing",
parent: folderId,
});
// try to search for it again
const foundFolder = await tsGoogleDrive
.query()
.setFolderOnly()
.setModifiedTime("=", newFolder.modifiedAt)
.runOnce();
}
// async function uploadAndDownload() {
// const folderId = "";
// const filename = "./icon.png";
// const newFile = await tsGoogleDrive.upload(filename, {parent: folderId});
// const downloadBuffer = await newFile.download();
// // you have to use "googleapis" package
// // of if you want stream
// const drive = google.drive({version: "v3", auth: newFile.client});
// const file = await drive.files.get({
// fileId: newFile.id,
// alt: 'media'
// }, {responseType: "stream"});
// file.data.on("data", data => {
// // stream data
// });
// file.data.on("end", () => {
// // stream end
// });
// // or use pipe
// const writeStream = fs.createWriteStream('./output.png');
// file.data.pipe(writeStream);
// }
async function search() {
const folderId = "";
const query = await tsGoogleDrive
.query()
.setFolderOnly()
.inFolder(folderId)
.setPageSize(3)
.setOrderBy("name")
.setNameContains("New");
// or you can use any query https://developers.google.com/drive/api/v3/search-files
query.setQuery("name = 'hello'");
while (query.hasNextPage()) {
const folders = await query.run();
for (const folder of folders) {
await folder.delete();
}
}
}
async function emptyTrash() {
await tsGoogleDrive.emptyTrash();
}
const drive1 = new TsGoogleDrive({keyFilename: "serviceAccount.json"});
const drive2 = new TsGoogleDrive({credentials: {client_email: "", private_key: ""}});
const drive3 = new TsGoogleDrive({oAuthCredentials: {access_token: ""}});
const drive4 = new TsGoogleDrive({oAuthCredentials: {refresh_token: ""}, oauthClientOptions: {clientId: "", clientSecret: ""}});
FAQs
Manage google drive easily. Support create folders, upload files, download files, searching, etc..
The npm package browser-ts-google-drive receives a total of 0 weekly downloads. As such, browser-ts-google-drive popularity was classified as not popular.
We found that browser-ts-google-drive demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.