lukepighetti / mastodon_dart

Unofficial 🐘 client written in 🎯
https://pub.dev/packages/mastodon_dart
MIT License
28 stars 8 forks source link

Add files support #47

Closed abraham closed 1 year ago

abraham commented 1 year ago

Validated with:

import 'package:mastodon_dart/mastodon_dart.dart';

const bearerToken = '';
final website = Uri.parse('https://mstdn.party');

void main() async {
  var client = Mastodon(website);
  client.token = bearerToken;

  var attachment1 = await client.uploadAttachment(
    'cat.jpg',
    description: 'cat',
  );
  print('a1 ${attachment1.id}');

  // var attachment2 = await client.uploadAttachment('cat.jpg');
  // print('a2 ${attachment2.id}');

  var response = await client.publishStatus(
    status: 'Testing with media',
    mediaIds: [attachment1.id],
  );
  print('s1 ${response.id}');

  var response2 = await client.publishStatus(status: 'Testing without media');
  print('s2 ${response2.id}');
}