once again

This commit is contained in:
Inex Code 2022-04-21 06:54:29 +00:00
parent b6b58e8895
commit ef516ce396

View file

@ -106,16 +106,15 @@ Future<void> _postOnMastodon(reqJson) async {
options:
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
} else {
final mediaResponses = await photoUrls.map((photoUrl) async => await dio.post(
'$instanceUrl/api/v1/media',
data: dio_lib.FormData.fromMap({'file': File(photoUrl)}),
options:
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'})));
var mediaIds = [];
final mediaIds = mediaResponses.map((mediaResponse) {
final mediaId = mediaResponse.data['id'];
return mediaId;
}).toList();
for (final photoUrl in photoUrls) {
final resp = await dio.post('$instanceUrl/api/v1/media',
data: dio_lib.FormData.fromMap({'file': File(photoUrl)}),
options:
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
mediaIds.add(resp.data['id']);
}
await dio.post('$instanceUrl/api/v1/statuses',
data: {'status': postText, 'media_ids': mediaIds},