Skip to content

[WEB-Worker] Sending files via HTTP in a shared isolate: Is it possible? #49

@aldogdl

Description

@aldogdl

Is it possible to send files to a server via HTTP from a shared isolate in WEB?
If so, could you provide an example?
I've been having trouble with this and the error I receive when using the isolate is:
"ClientException: Null check operator used on a null value, uri='...'"
Thanks in advance!

EJEMPLO:

  var request = http.MultipartRequest('post', url);
  request.files.add(http.MultipartFile.fromBytes(
    'foto', List<int>.from(file['bytes'].toList()),
    filename: '${file['id']}.${file['ext']}', contentType: mime
  ));
  request.fields['datos'] = json.encode(
    Map<String, String>.from({
      'folder': folder, 'filename': '${file['id']}.${file['ext']}'
    })
  );
  request.headers['Content-Type'] = 'multipart/form-data';
  request.headers['Accept'] = 'application/json';

  print(request.files.first.field);
  print(request.files.first.contentType);
  print(request.files.first.length);
  print(request.files.first.filename);
  print(request.files.first);
  print(request.fields);
  print(request.files.first.isFinalized);
  print('----------------------------');

  http.StreamedResponse? response;
  try {
    response = await request.send();
  } catch (e) {
    return {'abort': true, 'body': e.toString()};
  }

Plugins:
http: ^1.3.0
http_parser: ^4.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions