Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files support #47

Merged
merged 1 commit into from
Dec 12, 2022
Merged

Add files support #47

merged 1 commit into from
Dec 12, 2022

Conversation

abraham
Copy link
Contributor

@abraham abraham commented Dec 12, 2022

  • Updates uploadAttachment to api v2
  • Limit publishStatus to a single mediaIds value as http doesn't support list values
  • Added MultipartRequest files support to post methods

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}');
}

@lukepighetti lukepighetti merged commit 4d223d3 into lukepighetti:main Dec 12, 2022
@abraham abraham deleted the media_ids branch December 12, 2022 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants