@draft-flysystem-ts/drop-box-adapter
this project is not completed yet
This adapter allows you to work with DropBox. Under the hood it use official DropBox SDK for node.js. It works in composite with main FileSystem class. Also you may find useful codebase in @draft-flysystem-ts/general module.
Be careful. This adapter does not support “visibility” property and related to it methods. This is due to the characteristics of the DropBox storage. Exception will be thrown. Also, since the official SDK does not work with streams, such methods as “.readStream()”, “.writeStream()” also does not supported. But these methods will be support in the future. Follow the updates of this repository.
import { Filesystem } from '@draft-flysystem-ts/flysystem';
import { DropboxAdapter } from '@draft-flysystem-ts/drop-box-adapter;
import { join } from 'path'
import 'dotenv/config';
async function example() {
const dropBoxAdapter = new DropboxAdapter({ accessToken: process.env.DBX_ACCESS });
const flysystem = new Filesystem(dropBoxAdapter);
}
import fs from 'fs';
async function upload(flysystem: Filesystem<DropboxAdapter>) {
const pathToFile = join(__dirname, 'relative/path/to/your/file.mp4');
await flysystem.write('your/drop-box/file.mp4', fs.readFileSync(pathToFile));
}
async function move(flysystem: Filesystem<DropboxAdapter>) {
await flysystem.move('your-dropbox/old-folder/file.mp4', 'your-dropbox/new-folder/file.mp4');
}
async function move(flysystem: Filesystem<DropboxAdapter>) {
await flysystem.copy('your-dropbox/origin-file.mp4', 'your-dropbox/copy-file.mp4');
}