Created
May 3, 2020 14:07
-
-
Save sankarcheppali/aac755fdba255e81b2b92cbe45fc13f3 to your computer and use it in GitHub Desktop.
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 'package:path/path.dart'; | |
import 'dart:io'; | |
import 'dart:async'; | |
import 'package:dio/dio.dart'; | |
/** | |
* accepts two parameters,the endpoint and the file | |
* returns Response from server | |
*/ | |
Future<Response> sendFile(String url, File file) async { | |
Dio dio = new Dio(); | |
var len = await file.length(); | |
var response = await dio.put(url, | |
data: file.openRead(), | |
options: Options(headers: { | |
Headers.contentLengthHeader: len, | |
} // set content-length | |
)); | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you give me full code or any example for this i nedd to uplode img and get url