
Company News
Socket Has Acquired Secure Annex
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.
Minio的官方客户端使用时必须依赖node.js, 无法在vite项目中使用, 此项目把minio的使用打包为纯js,可以在浏览器中直接调用minio的客户端
https://gitee.com/zheyiw/minio-js-m
https://www.npmjs.com/package/minio-js
yarn add minio-js
<template>
<div id="nav">
<p>vite中import使用miniojs上传文件</p>
<input ref="input" type="file" @change="handleFiles" />
</div>
</template>
<script lang="ts">
import { initMinio, putObject } from 'minio-js'
export default {
methods: {
handleFiles(event: any) {
var f = event.target.files[0]
let reader = new FileReader()
reader.readAsArrayBuffer(f)
reader.onload = function (e: any) {
let res = e.target.result //ArrayBuffer
//先初始化
initMinio({
endPoint: '192.168.2.98',
port: 9002,
useSSL: false,
accessKey: 'admin',
secretKey: '12345678',
})
//再上传
putObject("act", res, f.name)
console.log('上传完成')
}
},
},
}
</script>
以js的方法使用, 直接引用MinioJs.js文件(文件很大, 按需引入)
<html>
<head>
<title>MinioJs</title>
</head>
<body>
<div id="root">MinioJs</div>
<script type="text/javascript" src="./MinioJs.js"></script>
<script
type="text/javascript"
src="http://code.jquery.com/jquery-1.10.2.min.js"
></script>
<div id="nav">
<p>Minio文件上传:</p>
<form id="form"><input type="file" name="file" id="file" /><br /></form>
</div>
<script type="text/javascript">
$(function () {
form.reset(); //清除浏览器记录的上次记录
var file;
$(form).on("change", "#file", function (e) {
console.log(this.value); //文件路径
console.log(this.files[0].name); //文件名
//把文件以ArrayBuffer的形式读取后给Minio上传
var f = this.files[0];
let reader = new FileReader();
reader.readAsArrayBuffer(f);
reader.onload = function (e) {
let res = e.target.result; //ArrayBuffer
//先初始化
MinioJs.initMinio({
endPoint: "192.168.2.98",
port: 9002,
useSSL: false,
accessKey: "admin",
secretKey: "12345678",
});
//再上传
MinioJs.putObject("bucket1", res, f.name);
console.log("尝试上传中...");
};
});
});
</script>
</body>
</html>
把MinioJs.js放在public目录下面,在index.html中引入
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript" src="MinioJs.js"></script>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
使用
<template>
<div id="nav">
<p>MinioJs上传文件:</p>
<input ref="input" type="file" @change="handleFiles" />
</div>
</template>
<script lang="ts">
declare const MinioJs: any //定义
export default {
methods: {
handleFiles(event: any) {
var f = event.target.files[0]
let reader = new FileReader()
reader.readAsArrayBuffer(f)
reader.onload = function (e: any) {
let res = e.target.result //ArrayBuffer
//先初始化
MinioJs.initMinio({
endPoint: '192.168.2.98',
port: 9002,
useSSL: false,
accessKey: 'admin',
secretKey: '12345678',
})
//再上传
MinioJs.putObject("bucket1", res, f.name)
console.log('上传中...')
}
},
},
}
</script>
FAQs
minioclient
The npm package minio-js receives a total of 39 weekly downloads. As such, minio-js popularity was classified as not popular.
We found that minio-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.