FilePond在Vue -自定义标题



我目前通过ve - adapter在我的应用程序中使用FilePond,它工作得很好。

对于这个问题,我现在的代码是这样的:

<template>
<v-layout>
<v-flex class="text-center">
<FilePond
ref="pond"
name="file"
chunk-uploads="true"
:chunk-size="chunkSize"
class-name="my-pond"
label-idle="Drop files here..."
:allow-multiple="allowMultiple"
:files="myFiles"
:server="server"
@init="handleFilePondInit"
@error="error"
@processfile="updatefiles"
@addfile="testlog"
/>
</v-flex>
</v-layout>
</template>

server-属性看起来像这样:

computed: {
headers() {
return {
Authorization: this.$auth.getToken('local'),
projectId: this.projectId,
};
},
server() {
return {
url: 'http://localhost:3001/api/filepond/',
process: {
url: 'process',
headers: this.headers,
},
patch: {
url: 'patch?id=',
headers: this.headers,
},
};
},
chunkSize() {
return this.$config.chunk_size_byte;
},
},

这个设置工作得很好。FilePond按预期工作,我的自定义头被额外注入到FilePond提供的头。现在我遇到了一个问题,我需要文件名也在process-请求上,当patch-请求跟随时,通常不会发送。

我发现这个GitHub问题,这基本上是我的确切问题。

然而,如果我将计算的server值更改为以下代码,我的头根本不应用。

server() {
return {
url: 'http://localhost:3001/api/filepond/',
process: {
url: 'process',
headers: (file, metaData) => ({
Authorization: this.$auth.getToken('local'),
projectId: this.projectId,
filename: file.filename,
}),
},
patch: {
url: 'patch?id=',
headers: this.headers,
},
};
},

所以在尝试了很多之后,似乎有一个bug与vue-filepond,其中自定义头函数只应用,当上传文件与fileSize > chunkSize

我打开了一个问题,Rik暂时提供了一个解决方案(https://github.com/pqina/vue-filepond/issues/193)。

最新更新