Skip to content

Commit 49f330f

Browse files
fix(android): upload with content URIs (#14)
* fix(android): upload with content URIs" fix in native library version 1.0 References: ionic-team/ion-android-filetransfer#9 * chore: simplify example app
1 parent 243c4c4 commit 49f330f

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

packages/capacitor-plugin/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ repositories {
5858
dependencies {
5959
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'])
6060
implementation project(':capacitor-android')
61-
implementation "io.ionic.libs:ionfiletransfer-android:1.0.0"
61+
implementation "io.ionic.libs:ionfiletransfer-android:1.0.1"
6262
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
6363

6464
testImplementation "junit:junit:$junitVersion"

packages/example-app/src/js/file-transfer-app.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -336,30 +336,7 @@ window.customElements.define(
336336
const uploadProgressContainer = this.shadowRoot.querySelector('#uploadProgressContainer');
337337
uploadProgressContainer.style.display = uploadProgress.checked ? 'block' : 'none';
338338

339-
let filePath;
340-
341-
if (Capacitor.getPlatform() === 'web') {
342-
filePath = file.name;
343-
} else {
344-
const base64 = await new Promise((resolve, reject) => {
345-
const reader = new FileReader();
346-
reader.onload = () => {
347-
const result = reader.result;
348-
resolve(result.split(',')[1]);
349-
};
350-
reader.onerror = reject;
351-
reader.readAsDataURL(file);
352-
});
353-
354-
const savedFile = await Filesystem.writeFile({
355-
path: file.name,
356-
data: base64,
357-
directory: Directory.Cache,
358-
});
359-
360-
filePath = await savedFile.uri;
361-
}
362-
339+
let filePath = file.name;
363340
// Upload file
364341
const result = await FileTransfer.uploadFile({
365342
url,

0 commit comments

Comments
 (0)