diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-01-18 14:47:42 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2023-01-18 14:47:42 -0600 |
commit | d0364c09adeb922af5a0be7416a8b72468f46fd4 (patch) | |
tree | 7aa2da4d36108c342b1f83880b9b69a41d2b6c1e /src/state/lib/api.ts | |
parent | bf03167ca6709292852e01cd30a1a8106f6fc618 (diff) | |
download | voidsky-d0364c09adeb922af5a0be7416a8b72468f46fd4.tar.zst |
Hackfix around 'images too large' issue
Diffstat (limited to 'src/state/lib/api.ts')
-rw-r--r-- | src/state/lib/api.ts | 12 |
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 |