如何让类星体发送带有多部分/表单数据的大文件?
How to make quasar send large files with multipart / form-data?
我正在开发一个带有 quasar 应用程序的应用程序,但是当我使用该组件创建文件上传时,我无法发送小部分文件...
看代码...
<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 上将文件拆分为可管理的块,并在单独的消息中发送每个块。在服务器上,您必须收集所有块并将它们放在某个地方。大多数文件存储 APIs 都有某种分块上传 API。
在一些项目中,我只是使用 window.fetch 向我的 API 发送一个多部分请求。
另一个post中有一些教程和库:Can I upload a file to server by socket.io in node.js?
我正在开发一个带有 quasar 应用程序的应用程序,但是当我使用该组件创建文件上传时,我无法发送小部分文件...
看代码...
<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 上将文件拆分为可管理的块,并在单独的消息中发送每个块。在服务器上,您必须收集所有块并将它们放在某个地方。大多数文件存储 APIs 都有某种分块上传 API。
在一些项目中,我只是使用 window.fetch 向我的 API 发送一个多部分请求。
另一个post中有一些教程和库:Can I upload a file to server by socket.io in node.js?