[mob][photos] Enable multiPart upload for internal users

This commit is contained in:
Neeraj Gupta 2024-04-15 10:56:41 +05:30
parent 601a776b7a
commit 2638a06551
2 changed files with 14 additions and 4 deletions

View file

@ -29,6 +29,7 @@ import "package:photos/models/metadata/file_magic.dart";
import 'package:photos/models/upload_url.dart';
import "package:photos/models/user_details.dart";
import 'package:photos/services/collections_service.dart';
import "package:photos/services/feature_flag_service.dart";
import "package:photos/services/file_magic_service.dart";
import 'package:photos/services/local_sync_service.dart';
import 'package:photos/services/sync_service.dart';
@ -493,11 +494,15 @@ class FileUploader {
final String thumbnailObjectKey =
await _putFile(thumbnailUploadURL, encryptedThumbnailFile);
final count = await calculatePartCount(
await encryptedFile.length(),
);
// Calculate the number of parts for the file. Multiple part upload
// is only enabled for internal users and debug builds till it's battle tested.
final count = FeatureFlagService.instance.isInternalUserOrDebugBuild()
? await calculatePartCount(
await encryptedFile.length(),
)
: 1;
String fileObjectKey;
late String fileObjectKey;
if (count <= 1) {
final fileUploadURL = await _getUploadURL();

View file

@ -6,6 +6,7 @@ import "package:dio/dio.dart";
import "package:logging/logging.dart";
import "package:photos/core/constants.dart";
import "package:photos/core/network/network.dart";
import "package:photos/services/feature_flag_service.dart";
import "package:photos/utils/xml_parser_util.dart";
final _enteDio = NetworkClient.instance.enteDio;
@ -56,6 +57,10 @@ Future<int> calculatePartCount(int fileSize) async {
Future<MultipartUploadURLs> getMultipartUploadURLs(int count) async {
try {
assert(
FeatureFlagService.instance.isInternalUserOrDebugBuild(),
"Multipart upload should not be enabled for external users.",
);
final response = await _enteDio.get(
"/files/multipart-upload-urls",
queryParameters: {