requests icon indicating copy to clipboard operation
requests copied to clipboard

multipart http requests support (file uploads)

Open DonsWayo opened this issue 5 years ago • 4 comments

Is posible to create a multipart request with this library?

Thanks!

DonsWayo avatar Jan 01 '20 23:01 DonsWayo

it's a good feature. not yet implemented. would you like to fork this repo, add multipart support and submit a PR?

jossef avatar Jan 09 '20 06:01 jossef

Seems like this might be a good place to start (source):

var uri = Uri.parse('https://example.com/create');
var request = http.MultipartRequest('POST', uri)
  ..fields['user'] = '[email protected]'
  ..files.add(await http.MultipartFile.fromPath(
      'package', 'build/package.tar.gz',
      contentType: MediaType('application', 'x-tar')));
var response = await request.send();
if (response.statusCode == 200) print('Uploaded!');

mingsai avatar May 21 '20 00:05 mingsai

📣 Need help on this one. Please submit a PR 🙏

jossef avatar May 23 '20 18:05 jossef

+1 on this.

Requests has been a game changer. However I recently came across the need to upload images and find myself having to unwind this package from my app completely. This type of package is all-or-none so this is a must-need addition.

Holding out hope for this!

mark8044 avatar Jul 17 '21 00:07 mark8044