@flysystem-ts/drop-box-adapter
v1.4.1
Published
Adapter for work with https://www.dropbox.com/home
Downloads
12
Readme
@flysystem-ts/drop-box-adapter
Home
Description:
This adapter allows you to work with DropBox. Under the hood it uses official DropBox 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 { DBoxAdapter } from '@dflysystem-ts/drop-box-adapter';
import { join } from 'path'
import { readFileSync } from 'fs';
import 'dotenv/config';
async function example() {
const dropBoxAdapter = new DBoxAdapter({ accessToken: process.env.DBX_ACCESS });
const flysystem = Flysystem<DBoxAdapter>(dropBoxAdapter);
const { id } = await flysystem.mkdirById({
name: 'example'
});
const item = await flysystem.uploadById(readFileSync(join(__dirname, 'hi.txt')), {
name: 'hi.txt',
rootDirId: id,
});
}
Upload example:
import fs from 'fs';
async function upload(flysystem: Flysystem<DropboxAdapter>) {
const pathToFile = join(__dirname, 'relative/path/to/your/file.mp4');
await flysystem.uploadById(fs.readFileSync(pathToFile), {
name: 'cool.mp4',
});
}