Skip to content

Instantly share code, notes, and snippets.

@geeksilva97
Created June 3, 2021 17:04
Show Gist options
  • Save geeksilva97/b3e1348ad24a73955d9525fc3f07b477 to your computer and use it in GitHub Desktop.
Save geeksilva97/b3e1348ad24a73955d9525fc3f07b477 to your computer and use it in GitHub Desktop.
Http Upload Service
import 'dart:convert';
import 'package:http/http.dart' as http;
class HttpUploadService {
Future<String> uploadPhotos(List<String> paths) async {
Uri uri = Uri.parse('http://10.0.0.103:5000/profile/upload-mutiple');
http.MultipartRequest request = http.MultipartRequest('POST', uri);
for(String path in paths){
request.files.add(await http.MultipartFile.fromPath('files', path));
}
http.StreamedResponse response = await request.send();
var responseBytes = await response.stream.toBytes();
var responseString = utf8.decode(responseBytes);
print('\n\n');
print('RESPONSE WITH HTTP');
print(responseString);
print('\n\n');
return responseString;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment