Hi @ced,
Below is my code, please help
File f = File(el.imageFile.path);
String value = base64Encode(f.readAsBytesSync());
String kk = "{'__class__': 'bytes', 'base64':" + value+ "}";
List<Map<String, dynamic>> vlist = List<Map<String, dynamic>>();
vlist.add({
"resource": 'wms.receiving,6',
"name": 'Ref_doc_.jpg' ,
"data": value
});
Future<TrytonResponse> create(List vlist, {Map context}) async {
var ctx = await getContext();
var params = [vlist, ctx];
String method = "model.ir.attachment.create";
var body = json.encode({"id": new Uuid().v1(),
"method": method,
"params": params});
final res = await callRequest(payload);
return res;
}
Future<TrytonResponse> callRequest(payload) async {
var auth = '$_userName:$_uid:$_sessionId';
var bytes = utf8.encode(auth);
var base64 = base64Encode(bytes);
String sessionAuth = 'Session $base64';
Dio client = Dio();
client.options.headers["Content-type"] = "application/json; charset=UTF-8";
client.options.headers["Cookie"] = _sessionId;
client.options.headers["authorization"] = sessionAuth;
final response = await client.post(_serverURL, data: body);
TrytonResponse res = TrytonResponse(response);
res.checkError();
return res;
}