diff --git a/src/analytics/features/types.ts b/src/analytics/features/types.ts index 5c1857990e..b86c62e5ba 100644 --- a/src/analytics/features/types.ts +++ b/src/analytics/features/types.ts @@ -10,6 +10,7 @@ export enum Features { ImportContactsSettingsDisable = 'import_contacts:settings:disable', LiveNowBetaDisable = 'live_now_beta:disable', ImageUploadsHighResolution = 'image_uploads:high_resolution', + ImageUploadsBlobSize2mbEnabled = 'image_uploads:blob_size_2mb:enabled', GroupChatsEnable = 'group_chats:enable', DmsNewMessageComposerEnable = 'dms:new_message_composer:enable', diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 8755da5a23..1973afb3c1 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -53,6 +53,7 @@ interface PostOpts { type FeatureFlags = { highResolutionImages?: boolean + increasedBlobSizeLimit?: boolean } export async function post( @@ -320,6 +321,7 @@ async function resolveMedia( logger.debug(`Compressing image #${i}`) const {path, width, height, mime} = await compressImage(image, { highResolution: featureFlags?.highResolutionImages, + increasedBlobSizeLimit: featureFlags?.increasedBlobSizeLimit, }) logger.debug(`Uploading image #${i}`) const res = await uploadBlob(agent, path, mime) diff --git a/src/state/gallery.ts b/src/state/gallery.ts index d929dad11a..068e14fb28 100644 --- a/src/state/gallery.ts +++ b/src/state/gallery.ts @@ -204,6 +204,7 @@ export async function compressImage( img: ComposerImage, options?: { highResolution?: boolean + increasedBlobSizeLimit?: boolean }, ): Promise { const source = img.transformed || img.source @@ -211,6 +212,7 @@ export async function compressImage( let attempts = 0 let maxDimension = highResolution ? 4000 : POST_IMG_MAX.width + let maxBytes = options?.increasedBlobSizeLimit ? 2000000 : POST_IMG_MAX.size let minQualityPercentage = 0 let maxQualityPercentage = 101 // exclusive @@ -251,7 +253,7 @@ export async function compressImage( const base64 = res.base64 const size = base64 ? getDataUriSize(base64) : 0 - if (base64 && size <= POST_IMG_MAX.size) { + if (base64 && size <= maxBytes) { minQualityPercentage = qualityPercentage newDataUri = { path: await moveIfNecessary(res.uri), diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 2d076690d2..ceaa2fc395 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -838,6 +838,9 @@ export const ComposePost = ({ highResolutionImages: ax.features.enabled( ax.features.ImageUploadsHighResolution, ), + increasedBlobSizeLimit: ax.features.enabled( + ax.features.ImageUploadsBlobSize2mbEnabled, + ), }, ) ).uris[0]