@draft-flysystem-ts/drop-box-adapter
v1.0.1
Published
> TODO: description
Downloads
5
Readme
@draft-flysystem-ts/drop-box-adapter
this project is not completed yet
Description:
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.
Specifics of this adapter:
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.
Usage
Import and construct example:
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);
}
Upload example:
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));
}
Move (or rename) example:
async function move(flysystem: Filesystem<DropboxAdapter>) {
await flysystem.move('your-dropbox/old-folder/file.mp4', 'your-dropbox/new-folder/file.mp4');
}
Copy example:
async function move(flysystem: Filesystem<DropboxAdapter>) {
await flysystem.copy('your-dropbox/origin-file.mp4', 'your-dropbox/copy-file.mp4');
}