Filepicker.io(Filestack)上传两次

时间:2017-11-07 12:04:12

标签: angular filepicker.io

我在Angular 4应用程序中使用Filestack(aka filepicker.io)。当我选择一个文件时(在上传之前),它会自动上传。所以在按上传后,我将上传2个文件。我究竟做错了什么? :(

这是我的代码:

async showPicker() {

    const client = filestack.init('MyApiKey');

    const result = await client.pick({
        fromSources: ['local_file_system', 'webcam', 'imagesearch', 'facebook', 'instagram', 'googledrive', 'dropbox', 'picasa'],
        maxFiles: 1,
        minFiles: 1,
        transformations: {
            crop: {
                force: true,
                aspectRatio: 1
            }
        },
        accept: ['image/*']
    });

    const url = result.filesUploaded[0].url;
    this.uploadedFileUrls.push(url);
}

P.S。我已经检查了这个Filestack with Angular 2

1 个答案:

答案 0 :(得分:1)

目前,参数uploadInBackground将设置为' true'默认情况下,它启用后台上传。 如果你想禁用它,只需将uploadInBackground参数设置为false值插入代码中,如下所示:



async showPicker() {

    const client = filestack.init('MyApiKey');

    const result = await client.pick({
        fromSources: ['local_file_system', 'webcam', 'imagesearch', 'facebook', 'instagram', 'googledrive', 'dropbox', 'picasa'],
        maxFiles: 1,
        minFiles: 1,
        uploadInBackground: false,
        transformations: {
            crop: {
                force: true,
                aspectRatio: 1
            }
        },
        accept: ['image/*']
    });

    const url = result.filesUploaded[0].url;
    this.uploadedFileUrls.push(url);
}