about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/state/lib/api.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/state/lib/api.ts b/src/state/lib/api.ts
index 8dc9ce5f5..fd020aeee 100644
--- a/src/state/lib/api.ts
+++ b/src/state/lib/api.ts
@@ -6,10 +6,10 @@
 // import {ReactNativeStore} from './auth'
 import {
   sessionClient as AtpApi,
-  APP_BSKY_GRAPH,
   AppBskyEmbedImages,
   AppBskyEmbedExternal,
 } from '@atproto/api'
+import RNFS from 'react-native-fs'
 import {AtUri} from '../../third-party/uri'
 import {RootStoreModel} from '../models/root-store'
 import {extractEntities} from '../../lib/strings'
@@ -235,6 +235,16 @@ async function fetchHandler(
     typeof reqBody === 'string' &&
     (reqBody.startsWith('/') || reqBody.startsWith('file:'))
   ) {
+    if (reqBody.endsWith('.jpeg') || reqBody.endsWith('.jpg')) {
+      // HACK
+      // React native has a bug that inflates the size of jpegs on upload
+      // we get around that by renaming the file ext to .bin
+      // see https://github.com/facebook/react-native/issues/27099
+      // -prf
+      const newPath = reqBody.replace(/\.jpe?g$/, '.bin')
+      await RNFS.moveFile(reqBody, newPath)
+      reqBody = newPath
+    }
     // NOTE
     // React native treats bodies with {uri: string} as file uploads to pull from cache
     // -prf