Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sankarcheppali/aac755fdba255e81b2b92cbe45fc13f3 to your computer and use it in GitHub Desktop.
Save sankarcheppali/aac755fdba255e81b2b92cbe45fc13f3 to your computer and use it in GitHub Desktop.
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;
}
@Ankit70466
Copy link

can you give me full code or any example for this i nedd to uplode img and get url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment