remove old file get api use

This commit is contained in:
yaso 2026-07-10 11:09:56 +02:00
parent 8912e77b03
commit d7e4ac134d
19 changed files with 80 additions and 109 deletions

View file

@ -293,7 +293,7 @@ class MihBusinessDetailsServices {
businessMissionVision,
),
);
String newProPicUrl = await MihFileApi.getMinioFileUrl(filePath);
String newProPicUrl = MihFileApi.getMinioFileUrlV2(filePath);
provider.setBusinessProfilePicUrl(newProPicUrl);
return 200;
} else {

View file

@ -1,9 +1,6 @@
import 'dart:convert';
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:go_router/go_router.dart';
import 'package:ken_logger/ken_logger.dart';
import 'package:mih_package_toolkit/mih_package_toolkit.dart';
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
import 'package:flutter/material.dart';
@ -14,30 +11,30 @@ import 'package:supertokens_flutter/supertokens.dart';
class MihFileApi {
final baseAPI = AppEnviroment.baseApiUrl;
static Future<String> getMinioFileUrl(
String filePath,
) async {
String fileUrl = "";
try {
var url =
"${AppEnviroment.baseApiUrl}/minio/pull/file/${AppEnviroment.getEnv()}/$filePath";
var response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
var decodedData = jsonDecode(response.body);
fileUrl = decodedData['minioURL'];
} else {}
} catch (e) {
KenLogger.error("Error getting url");
} finally {}
if (AppEnviroment.getEnv() == "Dev" && kIsWeb) {
fileUrl = fileUrl.replaceAll("10.0.2.2", "127.0.0.1");
} else if (AppEnviroment.getEnv() == "Dev" && Platform.isIOS) {
fileUrl = fileUrl.replaceAll("10.0.2.2", "127.0.0.1");
} else if (AppEnviroment.getEnv() == "Dev" && Platform.isLinux) {
fileUrl = fileUrl.replaceAll("10.0.2.2", "127.0.0.1");
}
return fileUrl;
}
// static Future<String> getMinioFileUrl(
// String filePath,
// ) async {network
// String fileUrl = "";
// try {
// var url =
// "${AppEnviroment.baseApiUrl}/minio/pull/file/${AppEnviroment.getEnv()}/$filePath";
// var response = await http.get(Uri.parse(url));
// if (response.statusCode == 200) {
// var decodedData = jsonDecode(response.body);
// fileUrl = decodedData['minioURL'];
// } else {}
// } catch (e) {
// KenLogger.error("Error getting url");
// } finally {}
// if (AppEnviroment.getEnv() == "Dev" && kIsWeb) {
// fileUrl = fileUrl.replaceAll("10.0.2.2", "127.0.0.1");
// } else if (AppEnviroment.getEnv() == "Dev" && Platform.isIOS) {
// fileUrl = fileUrl.replaceAll("10.0.2.2", "127.0.0.1");
// } else if (AppEnviroment.getEnv() == "Dev" && Platform.isLinux) {
// fileUrl = fileUrl.replaceAll("10.0.2.2", "127.0.0.1");
// }
// return fileUrl;
// }
static String getMinioFileUrlV2(
String filePath,
@ -63,8 +60,13 @@ class MihFileApi {
request.fields['app_id'] = app_id;
request.fields['env'] = env;
request.fields['folder'] = folderName;
request.files.add(await http2.MultipartFile.fromBytes('file', file!.bytes!,
filename: file.name.replaceAll(RegExp(r' '), '-')));
request.files.add(
http2.MultipartFile.fromBytes(
'file',
await file!.readAsBytes(),
filename: file.name.replaceAll(RegExp(r' '), '-'),
),
);
var response = await request.send();
context.pop(); // Pop loading dialog
return response.statusCode;

View file

@ -1,5 +1,4 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
@ -22,9 +21,7 @@ class MIHLocationAPI {
MihAlertServices().locationPermissionAlert(context);
return null;
}
print("Before checkPermission"); // Debug
LocationPermission permission = await Geolocator.checkPermission();
print("After checkPermission: $permission"); // Debug
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {

View file

@ -140,7 +140,7 @@ class MihMyBusinessUserServices {
bUserAccess,
),
);
String newProPicUrl = await MihFileApi.getMinioFileUrl(filePath);
String newProPicUrl = MihFileApi.getMinioFileUrlV2(filePath);
provider.setBusinessUserSignatureUrl(newProPicUrl);
return 200;
} else {

View file

@ -221,7 +221,7 @@ class MihUserServices {
purpose,
),
);
String newProPicUrl = await MihFileApi.getMinioFileUrl(filePath);
String newProPicUrl = MihFileApi.getMinioFileUrlV2(filePath);
context.read<MzansiProfileProvider>().setUserProfilePicUrl(newProPicUrl);
return response.statusCode;
} else {