Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming problem #59

Open
AmirHosseinBaderan opened this issue Feb 3, 2024 · 0 comments
Open

Streaming problem #59

AmirHosseinBaderan opened this issue Feb 3, 2024 · 0 comments

Comments

@AmirHosseinBaderan
Copy link

AmirHosseinBaderan commented Feb 3, 2024

i want to send an IAsyncEnumerable to server for streaming
and i used multiple of types that all of them not working
my question is : how do i do it?

the code i wrote :

Future<FileResponse<FtmFile?>> upload(UploadFile file) async {
    try {
      await start();
      final request = await _uploadRequest(RequestUpload.fromUploadFile(file));
      if (request.status.toLowerCase() == 'success') {
        final base64 = base64Encode(file.buffer);
        final subject = Stream.fromIterable(_makeChunck(base64));
        final response = await _connection?.invoke(_FileMethods.upload, args: [
          request.result!,
          subject,
        ]);
        return FileResponse<FtmFile?>.fromJson(
            response as Map<String, Object?>);
      } else {
        return FileResponse(
          result: null,
          status: request.status,
        );
      }
    } catch (e) {
      return FileResponse(
        result: null,
        status: 'fail',
      );
    } finally {
      await _connection?.stop();
    }
  }

the error i get :
RangeError (RangeError (index): Invalid value: Valid value range is empty: 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant