Browse Source

once again

master
Inex Code 5 months ago
parent
commit
ef516ce396
  1. 19
      bin/server.dart

19
bin/server.dart

@ -106,16 +106,15 @@ Future<void> _postOnMastodon(reqJson) async { @@ -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'})));
final mediaIds = mediaResponses.map((mediaResponse) {
final mediaId = mediaResponse.data['id'];
return mediaId;
}).toList();
var mediaIds = [];
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},

Loading…
Cancel
Save