stuff
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
This commit is contained in:
parent
a882b9c7e6
commit
c14a7ba87e
2 changed files with 35 additions and 49 deletions
|
|
@ -23,15 +23,18 @@ class MediaApiV2 {
|
|||
|
||||
Router get router => _$MediaApiV2Router(this);
|
||||
|
||||
Response _ok(Object? object, {Map<String, String> headers = const {}}) =>
|
||||
Response(
|
||||
200,
|
||||
body: object == null ? null : jsonEncode(object),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Response _ok(Object? object, {Map<String, String> headers = const {}}) {
|
||||
final body = object == null ? null : jsonEncode(object);
|
||||
final responseHeaders = <String, String>{
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
if (body != null) 'Content-Length': body.length.toString(),
|
||||
...headers,
|
||||
},
|
||||
};
|
||||
return Response.ok(
|
||||
body,
|
||||
headers: responseHeaders,
|
||||
);
|
||||
}
|
||||
|
||||
Response _badRequest(String message) => Response.badRequest(
|
||||
body: jsonEncode({'error': 'Bad Request', 'message': message}),
|
||||
|
|
@ -74,10 +77,7 @@ class MediaApiV2 {
|
|||
await for (final part in multipart.parts) {
|
||||
// Check if this is the 'file' field
|
||||
final contentDisposition = part.headers['content-disposition'] ?? '';
|
||||
if (!contentDisposition.contains('name="file"')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (contentDisposition.contains('name="file"')) {
|
||||
// Read file bytes
|
||||
final chunks = <List<int>>[];
|
||||
await for (final chunk in part) {
|
||||
|
|
@ -95,8 +95,12 @@ class MediaApiV2 {
|
|||
final filenameMatch =
|
||||
RegExp(r'filename="?([^"]+)"?').firstMatch(contentDisposition);
|
||||
filename = filenameMatch?.group(1);
|
||||
|
||||
break; // Found file, no need to continue
|
||||
} else {
|
||||
// Read and discard other parts to ensure full request is consumed
|
||||
await for (final _ in part) {
|
||||
// Discard chunks from other parts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fileBytes == null) {
|
||||
|
|
|
|||
|
|
@ -224,22 +224,4 @@ class MockPackManager extends _i1.Mock implements _i8.PackManager {
|
|||
),
|
||||
)
|
||||
as _i5.Future<_i3.CardPackDto>);
|
||||
|
||||
@override
|
||||
_i5.Future<List<String>> getPackPreviewImages(String? packId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPackPreviewImages, [packId]),
|
||||
returnValue: _i5.Future<List<String>>.value(<String>[]),
|
||||
)
|
||||
as _i5.Future<List<String>>);
|
||||
|
||||
@override
|
||||
_i5.Future<Map<String, _i6.Uint8List>> getPackImages(String? packId) =>
|
||||
(super.noSuchMethod(
|
||||
Invocation.method(#getPackImages, [packId]),
|
||||
returnValue: _i5.Future<Map<String, _i6.Uint8List>>.value(
|
||||
<String, _i6.Uint8List>{},
|
||||
),
|
||||
)
|
||||
as _i5.Future<Map<String, _i6.Uint8List>>);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue