Created
June 3, 2021 17:04
-
-
Save geeksilva97/b3e1348ad24a73955d9525fc3f07b477 to your computer and use it in GitHub Desktop.
Http Upload Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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