add imgPath
This commit is contained in:
parent
4f12fdf8b3
commit
6fd00ddd98
@ -5,6 +5,7 @@ import 'package:intl/intl.dart';
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import '../classes/alert.dart';
|
import '../classes/alert.dart';
|
||||||
import '../classes/eventAdded.dart';
|
import '../classes/eventAdded.dart';
|
||||||
@ -116,6 +117,25 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
List<String> send = ["toto"];
|
List<String> send = ["toto"];
|
||||||
if (accessToken.isNotEmpty) {
|
if (accessToken.isNotEmpty) {
|
||||||
try {
|
try {
|
||||||
|
final params = {
|
||||||
|
'expiration': '600',
|
||||||
|
'key': '87a91f7e54516808dda2c4feffbd5287',
|
||||||
|
};
|
||||||
|
|
||||||
|
final urlPost = Uri.parse('https://api.imgbb.com/1/upload')
|
||||||
|
.replace(queryParameters: params);
|
||||||
|
File image = File(widget.imagePath);
|
||||||
|
Uint8List _bytes = await image.readAsBytes();
|
||||||
|
String _base64String = base64.encode(_bytes);
|
||||||
|
|
||||||
|
final req = http.MultipartRequest('POST', url)
|
||||||
|
..fields['image'] = _base64String;
|
||||||
|
|
||||||
|
final stream = await req.send();
|
||||||
|
final res = await http.Response.fromStream(stream);
|
||||||
|
|
||||||
|
final status = res.statusCode;
|
||||||
|
if (status == 200) {
|
||||||
//String credentials = "${pseudo}:${password}";
|
//String credentials = "${pseudo}:${password}";
|
||||||
//Codec<String, String> stringToBase64 = utf8.fuse(base64);
|
//Codec<String, String> stringToBase64 = utf8.fuse(base64);
|
||||||
//String encoded = stringToBase64.encode(credentials);
|
//String encoded = stringToBase64.encode(credentials);
|
||||||
@ -184,6 +204,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
}
|
}
|
||||||
showErrorDialog(context, text);
|
showErrorDialog(context, text);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
print("imgbb error : ${status}");
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showErrorDialog(context, "${e}");
|
showErrorDialog(context, "${e}");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user