Filepicker.io(文件堆栈)上传两次



我在我的 Angular 4 应用程序中使用 Filestack(又名 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);
}

附言我已经用 Angular 2 检查了这个文件堆栈

目前,参数 uploadInBackground 默认设置为 'true',这将启用后台上传。如果您希望禁用此功能,只需将设置为 false 值的 uploadInBackground 参数插入到代码中,如下所示:

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);
}

最新更新