@flysystem-ts/google-drive-adapter
v1.5.0
Published
> TODO: description
Downloads
9
Readme
@flysystem-ts/google-drive-adapter
Home
Description:
This adapter allows you to work with GoogleDrive. Under the hood it uses official GoogleDrive SDK for node.js. It works in composite with main Flysystem class. Also, you may find useful codebase in @flysystem-ts/common module.
Usage
Import and construct example:
import { Flysystem } from '@flysystem-ts/flysystem';
import { GDriveAdapter } from '@flysystem-ts/google-drive-adapter';
import { join } from 'path';
import { google } from 'googleapis';
import 'dotenv/config';
async function example() {
const oaut2Client = {} // ... see documentation how make authentication in googleapis
const gDriveAdapter = new GoogleDriveAdapter(google.drive({ version: 'v3', auth: oauth2Client });
const flysystem = Filesystem.init(dropBoxAdapter);
}
Upload example:
import fs from 'fs';
async function upload(flysystem: Filesystem) {
const pathToFile = join(__dirname, 'relative/path/to/your/file.mp4');
await flysystem.uploadById(fs.readFileSync(pathToFile), {
name: 'cool.mp4',
});
}