Siddhartha Maji
Siddhartha Maji

Reputation: 1052

Multipart file uploading in Flutter Web

Is there any way to multi-part upload file to the server for Flutter Web natively. Because there so many ways to do it for flutter iOS and Android.

Upvotes: 3

Views: 3934

Answers (1)

SeanThomas
SeanThomas

Reputation: 77

For Android/IOS we are using:

    multiPFile = await MultipartFile.fromFile(file.path,
          filename: file.name, contentType: MediaType.parse(mimeType));

For Web you need to build a MultiPartFile from the bytes of the file:

    multiPFile = await MultipartFile.fromBytes(file.bytes,
          filename: file.name, contentType: MediaType.parse(mimeType));

Upvotes: 4

Related Questions