This is an automated email from the ASF dual-hosted git repository. dimuthuupe pushed a commit to branch tus-integration in repository https://gitbox.apache.org/repos/asf/airavata-php-gateway.git commit cfea276b0e299e26e7909afbb1182bb3deaf972d Author: Dimuthu Wannipurage AuthorDate: Sat May 18 01:36:38 2019 -0400 Adding tus file upload support --- app/libraries/ExperimentUtilities.php | 61 +++++++++++++++++++++++---------- app/views/layout/fixed-header.blade.php | 3 ++ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php index b6295d5..4c4eb27 100755 --- a/app/libraries/ExperimentUtilities.php +++ b/app/libraries/ExperimentUtilities.php @@ -407,24 +407,26 @@ class ExperimentUtilities } } } elseif ($applicationInput->type == DataType::URI) { - if ($_FILES[$applicationInput->sanitizedFormName]['name']) { - $file = $_FILES[$applicationInput->sanitizedFormName]; - if ($file['error'] != 0) { - throw new Exception("Failure occurred while uploading file '" - . $file['name'] . "'. File upload error code is " . $file['error'] . "."); - } + if (isset($_POST[$applicationInput->sanitizedFormName]) && (trim($_POST[$applicationInput->sanitizedFormName]) != '')) { + + $tus_data_dir = "/data/gateway-user-data/tus-temp-dir/"; + $tus_download_url = trim($_POST[$applicationInput->sanitizedFormName]); + $file_uuid = explode("/", $tus_download_url)[4]; + $tus_bin_file = $tus_data_dir . $file_uuid . ".bin"; + $tus_info_file = $tus_data_dir . $file_uuid . ".info"; + $tus_info_file_as_str = file_get_contents($tus_info_file); + $tus_info_file_as_arr = json_decode($tus_info_file_as_str, true); + $file_name = $tus_info_file_as_arr["MetaData"]["filename"]; + $file_name = str_replace(' ', '_', $file_name); - //FIX - AIRAVATA - 2674 - //Replaced spaces with Underscore - $file['name'] = str_replace(' ', '_', $file['name']); - // // move file to experiment data directory // + $filePath = ""; if (!empty($applicationInput->value)) { $filePath = $experimentFilePath . $applicationInput->value; } else { - $filePath = $experimentFilePath . $file['name']; + $filePath = $experimentFilePath . $file_name; } // check if file already exists @@ -434,10 +436,9 @@ class ExperimentUtilities CommonUtilities::print_warning_message('Uploaded file already exists! Overwriting...'); } - $moveFile = move_uploaded_file($file['tmp_name'], $filePath); - + $moveFile = copy($tus_bin_file, $filePath); if (!$moveFile) { - CommonUtilities::print_error_message('

Error moving uploaded file ' . $file['name'] . '! + CommonUtilities::print_error_message('

Error moving uploaded file ' . $file_name . '! Please try again later or report a bug using the link in the Help menu.

'); $experimentAssemblySuccessful = false; } @@ -552,7 +553,7 @@ class ExperimentUtilities $experimentName = preg_replace('/[^a-zA-Z0-9]+/', '_', $experimentName); ExperimentUtilities::$relativeExperimentDataDir = "/" . Session::get('username') . "/" . $projectId . "/" - . $experimentName . time() . '/'; + . $experimentName . time() . '/'; ExperimentUtilities::$experimentPath = Config::get('pga_config.airavata')['experiment-data-absolute-path'] . ExperimentUtilities::$relativeExperimentDataDir; } while (is_dir(ExperimentUtilities::$experimentPath)); // if dir already exists, try again @@ -891,12 +892,12 @@ class ExperimentUtilities echo '
+ '" id="' . $input->sanitizedFormName . '" ' . $required . '>

' . $input->userFriendlyDescription . '

'; break; }else{ - echo '
+ /*echo '
view file
@@ -906,7 +907,31 @@ class ExperimentUtilities
Max Upload Size: ' . $allowedFileSize .'M

' . $input->userFriendlyDescription . '

-
'; + ';*/ + echo ' + +
+
+ +
+
+
+
'; + echo ''; break; } diff --git a/app/views/layout/fixed-header.blade.php b/app/views/layout/fixed-header.blade.php index c03e167..997c0b3 100644 --- a/app/views/layout/fixed-header.blade.php +++ b/app/views/layout/fixed-header.blade.php @@ -8,6 +8,9 @@ + + + {{ HTML::style('css/bootstrap.min.css')}}