From 82bb6f3f6c4bd016ea4e28e9cd6f8855cdb46ee3 Mon Sep 17 00:00:00 2001
From: "Piotr Kosko/Native/Web API (PLT) /SRPOL/Engineer/Samsung Electronics"
Date: Fri, 13 Mar 2020 12:27:07 +0100
Subject: [PATCH] [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
---
.../cordova-plugin-file-transfer/tizen/FileTransfer.js | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
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);
--
2.7.4