首页  >  问答  >  正文

如何自定义fetch方法以适用于FilePond文件上传器?

<p>我在使用FilePond的自定义<code>fetch</code>方法时遇到了一个问题,不知道该如何处理<code>load()</code>函数。文档要求将文件对象传递给<code>load()</code>方法,但我不知道如何获取它。我尝试传递<code>null</code>,但会抛出错误:这是代码:</p> <pre class="brush:php;toolbar:false;">server: { fetch: (url, load, error, progress, abort, headers) => { progress(true, 0, 1024); load(file); return { abort: () => { abort(); }, }; },</pre> <p>有什么想法吗?</p>
P粉129275658P粉129275658414 天前608

全部回复(1)我来回复

  • P粉340980243

    P粉3409802432023-09-02 16:18:50

    这是我在我的FilePond中从服务器获取文件时的做法。

    load: async (source, load, error, progress, abort, headers) => {
                let file = files.find(el => el.file == source)
                var myRequest = new Request(source);
                fetch(myRequest).then(function(response) {
                  response.blob().then(function(myBlob) {
                    load(myBlob);
                  });
                });

    回复
    0
  • 取消回复