我正在开发一个带有类星体应用程序的应用程序,但是当我使用该组件创建文件上传时,我无法以小部分发送文件......
看代码...
<template>
<q-uploader
multiple
auto-expand
:headers="{'content-type': 'multipart/form-data'}"
url=""
:upload-factory="uploadFile"
/>
</template>
<script>
import { mapActions } from 'vuex'
export default {
name: 'Uploader',
methods: {
uploadFile (file, updateProgress) {
// "file" is an Object containing file's props, including content
// for updating progress (as 0-1 floating number), we need to call:
// updateProgress (bytesTransferred / totalBytes)
this.uploadFilesSend({'file': file, 'type': file.type}).then(console.log('upload ok'))
// we need to return a Promise
// (resolves when upload is done, rejects when there's an error)
},
...mapActions('uploads', {
uploadFilesSend: 'create'
})
}
}
</script>
我使用feathersjs作为连接socket.io的服务器,服务器提示当我发送一个大文件时超时,甚至增加该团队更多我验证它只尝试发送整个文件而不是部分......
我想知道您是否有以及如何启用此多部分/表单数据方法..
感恩
最佳答案
您必须在 UI 上将文件拆分为可管理的 block ,并在单独的消息中发送每个 block 。在服务器上,您必须收集所有 block 并将它们放在某个地方。大多数文件存储 API 都有某种分块上传 API。
在一些项目中,我只是使用 window.fetch 向我的 API 发送多部分请求。
其他帖子中有一些教程和库:Can I upload a file to server by socket.io in node.js?
关于node.js - 如何使 quasar 使用 multipart/form-data 发送大文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55679785/