1.1.0 • Published 10 months ago

minio-import v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

Download from NPM

npm install --save minio-import

Initialize MinIO Client

You need five items in order to connect to MinIO object storage server.

ParamsDescription
endPointURL to object storage service.
portTCP/IP port number. This input is optional. Default value set to 80 for HTTP and 443 for HTTPs.
accessKeyAccess key is like user ID that uniquely identifies your account.
secretKeySecret key is the password to your account.
useSSLSet this value to 'true' to enable secure (HTTPS) access
import {Minio,Stream,Buffer} from 'minio-import'

var minioClient = new Minio.Client({
    endPoint: 'play.min.io',
    port: 9000,
    useSSL: true,
    accessKey: 'Q3AM3UQ867SPQQA43P2F',
    secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG'
});
/**
 * @params {file} 文件对象
 * @params {objeckKey} 在minio服务器上的存上路径
 *//
const handleUpload = (file, objectKey: string): any => {
  return new Promise<void>((resolve, reject): any => {
    // 将文件转换为minio可接收的格式
    const reader = new FileReader()
    reader.readAsArrayBuffer(file)
    reader.onloadend = (e: any) => {
      const bufferStream = new Stream.PassThrough()
      bufferStream.end(Buffer.from(e.target.result))
      minioClient.putObject(bucketName, objectKey, bufferStream, file.size, (err, etag) => {
        if (err) {
          reject(0)
        } else {
          resolve(etag)
        }
      })
    }
  })
}
1.1.0

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago