mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
Transfer repository from Gitlab
This commit is contained in:
17
mobile/lib/utils/dio_http_interceptor.dart
Normal file
17
mobile/lib/utils/dio_http_interceptor.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:immich_mobile/constants/hive_box.dart';
|
||||
|
||||
class AuthenticatedRequestInterceptor extends Interceptor {
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
// debugPrint('REQUEST[${options.method}] => PATH: ${options.path}');
|
||||
|
||||
var box = Hive.box(userInfoBox);
|
||||
|
||||
options.headers["Authorization"] = "Bearer ${box.get(accessTokenKey)}";
|
||||
options.responseType = ResponseType.plain;
|
||||
return super.onRequest(options, handler);
|
||||
}
|
||||
}
|
||||
33
mobile/lib/utils/files_helper.dart
Normal file
33
mobile/lib/utils/files_helper.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
class FileHelper {
|
||||
static getMimeType(String filePath) {
|
||||
var fileExtension = p.extension(filePath).split(".")[1];
|
||||
|
||||
switch (fileExtension) {
|
||||
case 'gif':
|
||||
return {"type": "image", "subType": "gif"};
|
||||
|
||||
case 'jpeg':
|
||||
return {"type": "image", "subType": "jpeg"};
|
||||
|
||||
case 'jpg':
|
||||
return {"type": "image", "subType": "jpeg"};
|
||||
|
||||
case 'png':
|
||||
return {"type": "image", "subType": "png"};
|
||||
|
||||
case 'mov':
|
||||
return {"type": "video", "subType": "quicktime"};
|
||||
|
||||
case 'mp4':
|
||||
return {"type": "video", "subType": "mp4"};
|
||||
|
||||
case 'avi':
|
||||
return {"type": "video", "subType": "x-msvideo"};
|
||||
|
||||
default:
|
||||
return {"type": "unsupport", "subType": "unsupport"};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user