From 947bdeb78acdb1ef3d645df8fd90849c2bd3eb17 Mon Sep 17 00:00:00 2001 From: nmahdi14 Date: Wed, 31 May 2023 15:26:56 +0330 Subject: [PATCH 1/2] Add file type to metadata --- .../main/java/io/tus/android/client/TusAndroidUpload.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tus-android-client/src/main/java/io/tus/android/client/TusAndroidUpload.java b/tus-android-client/src/main/java/io/tus/android/client/TusAndroidUpload.java index 4a626dc..ce2fba4 100644 --- a/tus-android-client/src/main/java/io/tus/android/client/TusAndroidUpload.java +++ b/tus-android-client/src/main/java/io/tus/android/client/TusAndroidUpload.java @@ -27,6 +27,11 @@ public TusAndroidUpload(Uri uri, Context context) throws FileNotFoundException { cursor.moveToFirst(); String name = cursor.getString(nameIndex); + String mimType = resolver.getType(uri); + if(mimType == null){ + mimType = "application/octet-stream"; + } + // On some files, ContentResolver#query will report the wrong filesize // even though the InputStream reads the correct length. This discrepancy // causes mismatching upload offsets when the upload should be finished. @@ -52,6 +57,7 @@ public TusAndroidUpload(Uri uri, Context context) throws FileNotFoundException { Map metadata = new HashMap<>(); metadata.put("filename", name); + metadata.put("filetype", mimType); setMetadata(metadata); cursor.close(); From 5f691cbe188e0c64b673bb71d2ddfe635d2ef919 Mon Sep 17 00:00:00 2001 From: nmahdi14 Date: Wed, 31 May 2023 15:48:05 +0330 Subject: [PATCH 2/2] add client.enableRemoveFingerprintOnSuccess() in MainActivity --- example/src/main/java/io/tus/android/example/MainActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/example/src/main/java/io/tus/android/example/MainActivity.java b/example/src/main/java/io/tus/android/example/MainActivity.java index 84f9e88..7295587 100644 --- a/example/src/main/java/io/tus/android/example/MainActivity.java +++ b/example/src/main/java/io/tus/android/example/MainActivity.java @@ -47,6 +47,7 @@ protected void onCreate(Bundle savedInstanceState) { client = new TusClient(); client.setUploadCreationURL(new URL("https://tusd.tusdemo.net/files/")); client.enableResuming(new TusPreferencesURLStore(pref)); + client.enableRemoveFingerprintOnSuccess(); } catch (Exception e) { showError(e); }