From: Piotr Kosko/Native/Web API (PLT) /SRPOL/Engineer/Samsung Electronics
Date: Fri, 13 Mar 2020 11:27:07 +0000 (+0100)
Subject: [FileTransfer] Fixing upload method for strict typing check
X-Git-Tag: submit/tizen/20200313.122957^0
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=82bb6f3f6c4bd016ea4e28e9cd6f8855cdb46ee3;p=platform%2Fcore%2Fapi%2Fcordova-plugins.git
[FileTransfer] Fixing upload method for strict typing check
[Bug] Because of strict type control in M76 Chromium update,
object passed to FormData need to inherit from JS
built-in type - Blob.
[Verification]
tct-file-transfer-cordova-tests 100% (TM1 tizen-unified_20200312.1)
Change-Id: Ib0496113555bee8615e519802e3ce0a9d165b6fa
---
diff --git a/src/lib/plugins/cordova-plugin-file-transfer/tizen/FileTransfer.js b/src/lib/plugins/cordova-plugin-file-transfer/tizen/FileTransfer.js
index e84fb2a..2042474 100755
--- a/src/lib/plugins/cordova-plugin-file-transfer/tizen/FileTransfer.js
+++ b/src/lib/plugins/cordova-plugin-file-transfer/tizen/FileTransfer.js
@@ -98,6 +98,7 @@ exports = {
function successCB(entry) {
if (entry.isFile) {
+ var fullPath = entry.toURL();
entry.file(function(file) {
function uploadFile(blobFile) {
var fd = new FormData();
@@ -161,7 +162,18 @@ exports = {
}
}
- uploadFile(file);
+ var fileHandle;
+ try {
+ fileHandle = tizen.filesystem.openFile(fullPath, 'r');
+ var fileBlob = fileHandle.readBlob();
+ uploadFile(fileBlob);
+ } catch (e) {
+ fail(FileTransferError.ABORT_ERR, 'Could not read file');
+ } finally {
+ if (fileHandle) {
+ fileHandle.close();
+ }
+ }
}, function(error) {
fail(FileTransferError.CONNECTION_ERR);