async minioUpload(contentFile) {
this.$myHttp({
method: 'get',
url: `${this.prefix}/doc/sysAttach/getFrontUploadMinioAttach?fileName=${contentFile.name}&fileSize=${contentFile.size}`,
data: '',
headers: { 'Authorization': 'Sys ' + sessionStorage.getItem('token'), 'showLoading':'false' }
}).then((res) => {
const data = res.data
this.minioUploadMth(data,contentFile)
})
.catch((error) => {
this.$message.error(error)
})
},
minioUploadMth(data,contentFile){
console.log('contentFile')
const minioClient = new Minio.Client({
endPoint: '192.168.209.93',
port: 9999,
useSSL: false, // 是否使用ssl
accessKey: 'minioadmin',
secretKey: 'minioadmin'
})
let that=this
this.getFileStream(contentFile).then((fileStream)=>{
console.log('123------',contentFile)
console.log("--------------",data.attachPath, fileStream, contentFile.size, contentFile.type)
minioClient.putObject('no-version-bucket', data.attachPath, fileStream, contentFile.size, null, function(err, etag) {
//1002: 上传成功, 1003: 上传失败
let tempTransferStatus=null
if (err){
console.log('minio上传',err, etag)
tempTransferStatus=1003
that.$message.error(err)
return
}
console.log('File uploaded successfully.');
tempTransferStatus=1002
//上传成功告诉后台
that.$myHttp({
method: 'post',
url: `${that.prefix}/doc/sysAttach/updateTransStatus`,
data: {
id:data.id,
transferStatus:tempTransferStatus
},
headers: { 'Authorization': 'Sys ' + sessionStorage.getItem('token'), 'showLoading':'false' }
})
})
})
},
getFileStream(file) {
return new Promise((resolve, reject) => {
let reader = new FileReader()
reader.readAsText(file)// 将文件转换为字符串
reader.onload = (e) => {
resolve(reader.result)
}
reader.onerror = () => { // 文件读取失败时触发
reject(reader.error)
}
},
getFileStream光将文件转换为字符串就需要特别长的时间,再到切片,而且上传上去的文件比原来大了,再下载下来也不对
首先这个网络带宽确认是不是限制了,然后再下载下来不对,是哪不对,是无法正常使用还是怎么了