numandev1 / react-native-compressor

🗜️Compress Image, Video, and Audio same like Whatsapp 🚀✨

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Android] backgroundUpload crashes when no uploadType provided

jblarriviere opened this issue · comments

Hi ! Thanks for working on this project, we're very happy with ! Here is a bug I noticed.
I'm happy to work on a PR, just let me know if I should handle the default value on the TS side or in the Android implem (or both) !

Current behavior

Calling backgroundUpload without providing and uploadType in the uploader options throws a NoSuchKeyException: uploadType error on Android

Expected behavior

Calling backgroundUpload without uploadType should not throw. uploadType should default to UploadType.BINARY_CONTENT as expected when reading the types (and as implemented in iOS)

export declare type UploaderOptions = (
  | {
      uploadType?: UploadType.BINARY_CONTENT;
      mimeType?: string;
    }
  | {
      uploadType: UploadType.MULTIPART;
      fieldName?: string;
      mimeType?: string;
      parameters?: Record<string, string>;
    }
) & {
  headers?: Record<string, string>;
  httpMethod?: UploaderHttpMethod;
  getCancellationId?: (cancellationId: string) => void;
};

Platform

  • Android
  • iOS

React Native Version

0.72.7

React Native Compressor Version

1.8.22

Reproducible Steps And Demo

Run example app on Android with line 255 of example/src/Screens/Video/index.tsx commented out. => No TS error
Navigate to Video Screen and try any Upload(PUT) button
See result here

(Should happen without any code modification on the exampleExpo app but I did not manage to build it)

👋 @jblarriviere
Thanks for opening your issue here! If you find this package useful hit the star🌟!