【问题标题】:Filepicker.io (Filestack) uploads twiceFilepicker.io (Filestack) 上传两次
【发布时间】:2017-11-07 12:04:12
【问题描述】:

我在我的 Angular 4 应用程序中使用 Filestack(又名 filepicker.io)。当我选择一个文件(并在上传之前)时,它会自动上传。所以在我按下 Upload 后,我将上传 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);
}

附:我已经检查过这个Filestack with Angular 2

【问题讨论】:

    标签: angular filepicker.io


    【解决方案1】:

    目前参数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);
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-20
      • 1970-01-01
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多