【问题标题】:Flutter File Picker Cross:- Failed to execute 'setItem' on 'Storage': Setting the value of 'file_picker_cross_file_system' exceeded the quotaFlutter File Picker Cross:-无法在“Storage”上执行“setItem”:设置“file_picker_cross_file_system”的值超出了配额
【发布时间】:2021-07-21 13:38:52
【问题描述】:

我正在构建一个 Flutter Web 应用程序,它选择多个文件并使用套接字将它们上传到服务器。对于 Flutter,这里是我正在使用的包

这是我的 pubspec.yaml 文件

dependencies:
  flutter:
    sdk: flutter
    cupertino_icons: ^1.0.1
    file_picker_cross: ^4.3.2
    http: ^0.13.1
    socket_io_client: ^2.0.0-beta.2

这里是选择文件和初始化套接字的函数

    void _selectFile(context) {
      FilePickerCross.importMultipleFromStorage().then((filePicker) {
      filePicker.forEach((element) {
      setFilePicker(element);
       });
      });
   }
  setFilePicker(FilePickerCross filePicker) => setState(() {
    filePickerCross = filePicker;
    filePickerCross.saveToPath(path: filePickerCross.fileName);
    // FilePickerCross.quota().then((value) {
    //   setState(() => quota = value);
    // });
    lastFiles.add(filePickerCross.fileName);

    try {
      _fileString = filePickerCross.toString();
    } catch (e) {
      _fileString = filePickerCross.toBase64();
    }
  });

  _socketClient() async {
print("auto true");
var socket = io.io('http://localhost:3010', <String, dynamic>{
  'transports': ['websocket'],
  'autoConnect': true,
});

socket.on('connect', (_) {
  print('connect');
  socket.emit(
    'filedetails',
    {
      'data': _fileString,
      'path': filePickerCross.path,
      'len': filePickerCross.length,
    },
  );
});
socket.on('event', (data) => print(data));
socket.on('disconnect', (_) => print('disconnect'));
socket.on('fromServer', (_) {
  setState(() {
    msgRx = 'From server: $_';
  });
});
socket.on('connect_error', (_) => print('socket connect_error: $_'));
socket.on('error', (_) => print('socket error: $_'));

}

我有一个使用套接字的简单 NodeJS 服务器,我在其中等待来自客户端的连接。 当我连接到服务器时,我收到以下错误

DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'file_picker_cross_file_system' exceeded the quota.
at Storage.[_setItem] (http://localhost:52078/dart_sdk.js:97142:27)
at Storage.[dartx._set] (http://localhost:52078/dart_sdk.js:97072:25)
at Object.saveLocalFileSystem (http://localhost:52078/packages/file_picker_cross/src/file_picker_web.dart.lib.js:296:36)
at saveInternalBytes (http://localhost:52078/packages/file_picker_cross/src/file_picker_web.dart.lib.js:201:23)
at saveInternalBytes.next (<anonymous>)
at runBody (http://localhost:52078/dart_sdk.js:39051:34)
at Object._async [as async] (http://localhost:52078/dart_sdk.js:39082:7)
at Object.saveInternalBytes (http://localhost:52078/packages/file_picker_cross/src/file_picker_web.dart.lib.js:198:18)
at file_picker_cross.FilePickerCross.new.saveToPath (http://localhost:52078/packages/file_picker_cross/src/file_picker_web.dart.lib.js:388:30)
at http://localhost:52078/packages/photo_measure/poc/socket_io_img_video.dart.lib.js:875:30
at socket_io_img_video._SocketIoClientPocFileUploadState.new.setState (http://localhost:52078/packages/flutter/src/widgets/widget_span.dart.lib.js:16616:22)      
at socket_io_img_video._SocketIoClientPocFileUploadState.new.setFilePicker
(http://localhost:52078/packages/photo_measure/poc/socket_io_img_video.dart.lib.js:873:19)
at http://localhost:52078/packages/photo_measure/poc/socket_io_img_video.dart.lib.js:865:16
at Array.[dartx.forEach] (http://localhost:52078/dart_sdk.js:15665:11)
at http://localhost:52078/packages/photo_measure/poc/socket_io_img_video.dart.lib.js:864:29
at _RootZone.runUnary (http://localhost:52078/dart_sdk.js:38888:58)
at _FutureListener.then.handleValue (http://localhost:52078/dart_sdk.js:33874:29)
at handleValueCallback (http://localhost:52078/dart_sdk.js:34434:49)
at Function._propagateToListeners (http://localhost:52078/dart_sdk.js:34472:17)
at _Future.new.[_completeWithValue] (http://localhost:52078/dart_sdk.js:34314:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:52078/dart_sdk.js:34337:35)
at Object._microtaskLoop (http://localhost:52078/dart_sdk.js:39175:13)
at _startMicrotaskLoop (http://localhost:52078/dart_sdk.js:39181:13)
at http://localhost:52078/dart_sdk.js:34688:9

【问题讨论】:

    标签: node.js flutter socket.io flutter-web


    【解决方案1】:

    我能够解决这个问题。 每当套接字已满时,我都会调用 dispose 函数。调用 dispose 时,套接字会刷新。

    从而纠正错误

    【讨论】:

      猜你喜欢
      • 2021-07-28
      • 2018-09-30
      • 2014-07-21
      • 1970-01-01
      • 1970-01-01
      • 2018-05-30
      • 1970-01-01
      • 2023-03-20
      • 2021-03-23
      相关资源
      最近更新 更多