I've got a REST api which assumes a multipartfile in the a post method.
Is there any way to do this kind of posts in Dart / AngularDart because all the solutions I've found so far are not working.
I've tried to use the http://dart-gde.github.io/dart-google-oauth2-library/multipart_file/MultipartFile.html solution, but it is not working in the browser because dart.io is not supported there.
My question is about the client side part directly from the browser. The serverside, which is written in Java can handle the post.
I know this was asked a long time ago, but I've just had the same problem and the fix for me is the following (based on luizmineo's answer):
formData.appendBlob("data", fileData);
Content-Type
header. This will get Dart to calculate theboundary
section of the form-data which is crucial.If you need multipart for file upload, all you have to do is send a
FormData
object using theHttpRequest
class. Example:Furthermore, if you need to allow the user to upload a file from his hard disk, you have to use a html form with an
<input type="file">
tag. Example:Html file:
dart file:
I finally found a way to post it as a multi-part form:
is used in conjunction with