Extended drive provider for AdonisJS 5.
npm i adonis-datadrive
node ace configure adonis-datadrive
import DataDrive from '@ioc:Zakodium/DataDrive';
const drive = DataDrive.use('myDrive');
// drive.put('myfile.txt', 'mycontent').then(...);
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
// Library importation
import DataDrive from '@ioc:Zakodium/DataDrive';
export default class FilesController {
public async upload({ request, params }: HttpContextContract) {
const { filename } = params;
request.multipart.onFile(filename, {}, async (file) => {
// Saves the file
await DataDrive.use('dir').put(filename, file);
});
await request.multipart.process();
return `${filename} uploaded`;
}
}