GithubHelp home page GithubHelp logo

fuxinko / adonis-drive-minio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ahmadarif/adonis-drive-minio

0.0 0.0 0.0 33 KB

Minio driver for Adonis Drive

License: MIT License

JavaScript 100.00%

adonis-drive-minio's Introduction

adonis-drive-minio ๐Ÿ’พ

npm version npm npm

Minio driver for AdonisJS Drive

Requirements

Installation

adonis install adonis-drive-minio

Instructions

Make sure to register the provider inside start/app.js file.

const providers = [
  ...
  'adonis-drive-minio/providers/DriveProvider'
]

Add new configuration inside disks module in config/drive.js:

minio: {
  driver: 'minio',
  host: Env.get('MINIO_HOST'),
  port: Env.get('MINIO_PORT'),
  secure: Env.get('MINIO_SECURE'),
  accessKey: Env.get('MINIO_ACCESS'),
  secretKey: Env.get('MINIO_SECRET'),
  bucket: Env.get('MINIO_BUCKET'),
  region: Env.get('MINIO_REGION')
}

Add minio variables in .env file:

MINIO_HOST=
MINIO_PORT=
MINIO_SECURE=
MINIO_ACCESS=
MINIO_SECRET=
MINIO_BUCKET=
MINIO_REGION=

Examples

exists(relativePath) -> Boolean

Find if a file exists or not.

const isExists = await Drive.disk('minio').exists('adonis.jpeg')

get(relativePath, outputPath) -> String

Downloads and saves the object as a file in the local filesystem.

const path = await Drive.disk('minio').get('adonis.jpeg', Helpers.tmpPath('adonis.jpeg'))

getUrl(relativePath, bucket?) -> String

Returns url for a given key. Note this method doesn't validates the existence of file or it's visibility status.

const url = await Drive.disk('minio').getUrl('adonis.jpeg')

getSignedUrl(relativePath, expiry?) -> String

Presigned URLs are generated for temporary download/upload access to private objects.

// url is valid for 10 minutes
const url = await Drive.disk('minio').getSignedUrl
('adonis.jpeg')

// url is valid for one hour
const url = await Drive.disk('minio', 3600).getSignedUrl
('adonis.jpeg')

put(filePath, relativePath?) -> String

Create a new file.

// url = bucketname/adonis.jpeg
const url = await Drive.disk('minio').put('/home/pictures/adonis.jpeg')

// url = bucketname/uploaded.jpeg
const url = await Drive.disk('minio').put('/home/pictures/adonis.jpeg', 'uploaded.jpeg')

delete(relativePath) -> Boolean

Remove a file.

const isDeleted = await Drive.disk('minio').delete('adonis.jpeg')

copy(src, dest, destBucket?) -> String

Copy file from one location to another within.

// copied in the same bucket
const url = await Drive.disk('minio').copy('adonis.jpeg', 'adonis-2.jpeg')

// copied to "other-bucket" bucket
const url = await Drive.disk('minio').copy('adonis.jpeg', 'adonis-2.jpeg', 'other-bucket')

move(src, dest, destBucket?) -> String

Move file from one location to another within.

// moved in the same bucket
const url = await Drive.disk('minio').move('adonis.jpeg', 'new-adonis.jpeg')

// moved to "other-bucket" bucket
const url = await Drive.disk('minio').move('adonis.jpeg', 'adonis-2.jpeg', 'other-bucket')

Change bucket

You can change bucket at runtime, just passing the bucket name before action.

const isExists = await Drive.disk('minio').bucket('new-bucket').exists('adonis.jpeg')

Thanks

Special thanks to the creator(s) of AdonisJS for creating such a great framework.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.