From commits-return-20579-archive-asf-public=cust-asf.ponee.io@airavata.apache.org Sat May 18 05:36:55 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 9D49A180675 for ; Sat, 18 May 2019 07:36:54 +0200 (CEST) Received: (qmail 94972 invoked by uid 500); 18 May 2019 05:36:53 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 94955 invoked by uid 99); 18 May 2019 05:36:53 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 May 2019 05:36:53 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id F1ACB85CE0; Sat, 18 May 2019 05:36:49 +0000 (UTC) Date: Sat, 18 May 2019 05:36:50 +0000 To: "commits@airavata.apache.org" Subject: [airavata-php-gateway] 01/01: Adding tus file upload support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: dimuthuupe@apache.org In-Reply-To: <155815780991.20975.14466521004913883391@gitbox.apache.org> References: <155815780991.20975.14466521004913883391@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: airavata-php-gateway X-Git-Refname: refs/heads/tus-integration X-Git-Reftype: branch X-Git-Rev: cfea276b0e299e26e7909afbb1182bb3deaf972d X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190518053649.F1ACB85CE0@gitbox.apache.org> 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')}}