Skip to content

Commit

Permalink
Merge pull request #205 from spoonconsulting/fix-note8
Browse files Browse the repository at this point in the history
Fix note8
  • Loading branch information
zfir authored Mar 29, 2022
2 parents 87f37c4 + f72e9f0 commit 610064c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dependency id="cordova-plugin-file" version="6.0.2"/>
<platform name="android">
<framework src="androidx.work:work-runtime:2.7.1" />
<framework src="com.squareup.okhttp3:okhttp:4.9.0" />
<framework src="com.squareup.okhttp3:okhttp:4.9.3" />
<framework src="androidx.room:room-runtime:2.4.2" />
<framework src="src/android/config.gradle" custom="true" type="gradleReference"/>
<config-file target="res/xml/config.xml" parent="/*">
Expand Down
9 changes: 8 additions & 1 deletion src/android/UploadTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,14 @@ private Request createRequest() throws FileNotFoundException {

// Build file reader
String extension = MimeTypeMap.getFileExtensionFromUrl(filepath);
MediaType mediaType = MediaType.parse(MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension));
MediaType mediaType;
if (extension.equals("json")) {
// Does not support devices less than Android 10 (Stop Execution)
// https://stackoverflow.com/questions/44667125/getmimetypefromextension-returns-null-when-i-pass-json-as-extension
mediaType = MediaType.parse(MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) + "; charset=utf-8");
} else {
mediaType = MediaType.parse(MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension));
}
File file = new File(filepath);
ProgressRequestBody fileRequestBody = new ProgressRequestBody(mediaType, file.length(), new FileInputStream(file), this::handleProgress);

Expand Down

0 comments on commit 610064c

Please sign in to comment.