fix(jellyfin): upload artwork as binary
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart' show visibleForTesting;
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
@@ -68,7 +68,7 @@ mixin _JellyfinMetadataEditMethods on MediaServerCacheMixin {
|
||||
}) async {
|
||||
final response = await _http.post(
|
||||
'/Items/${_segment(itemId)}/Images/${_segment(imageType)}',
|
||||
body: base64Encode(bytes),
|
||||
body: bytes,
|
||||
headers: {'Content-Type': contentType},
|
||||
);
|
||||
throwIfHttpError(response);
|
||||
|
||||
@@ -3016,15 +3016,15 @@ void main() {
|
||||
expect(requests[1].queryParameters['imageUrl'], 'https://img.example/poster.jpg');
|
||||
});
|
||||
|
||||
test('uploadItemImage sends base64 image body and image content type', () async {
|
||||
test('uploadItemImage sends binary image body and image content type', () async {
|
||||
Uri? capturedUri;
|
||||
String? capturedBody;
|
||||
List<int>? capturedBody;
|
||||
Map<String, String>? capturedHeaders;
|
||||
final client = JellyfinClient.forTesting(
|
||||
connection: _conn(),
|
||||
httpClient: MockClient((request) async {
|
||||
capturedUri = request.url;
|
||||
capturedBody = request.body;
|
||||
capturedBody = request.bodyBytes;
|
||||
capturedHeaders = request.headers;
|
||||
return http.Response('', 204);
|
||||
}),
|
||||
@@ -3040,7 +3040,7 @@ void main() {
|
||||
|
||||
expect(success, isTrue);
|
||||
expect(capturedUri!.path, '/Items/item-1/Images/Primary');
|
||||
expect(capturedBody, base64Encode([0xff, 0xd8, 0xff, 0x00]));
|
||||
expect(capturedBody, [0xff, 0xd8, 0xff, 0x00]);
|
||||
expect(capturedHeaders!['Content-Type'] ?? capturedHeaders!['content-type'], 'image/jpeg');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user