airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject airavata-php-gateway git commit: file upload creates files under user home dir
Date Sun, 01 Nov 2015 20:49:22 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/file-management [created] dbf6db428


file upload creates files under user home dir


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/dbf6db42
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/dbf6db42
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/dbf6db42

Branch: refs/heads/file-management
Commit: dbf6db4282168ded8d0d965bdc5814a328b091a6
Parents: 8eeb7be
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Sun Nov 1 15:49:17 2015 -0500
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Sun Nov 1 15:49:17 2015 -0500

----------------------------------------------------------------------
 app/controllers/DownloadFileController.php | 21 +++++++++++++++++++++
 app/libraries/ExperimentUtilities.php      | 14 ++++++++++++--
 app/routes.php                             |  3 +++
 3 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/dbf6db42/app/controllers/DownloadFileController.php
----------------------------------------------------------------------
diff --git a/app/controllers/DownloadFileController.php b/app/controllers/DownloadFileController.php
new file mode 100644
index 0000000..99151e8
--- /dev/null
+++ b/app/controllers/DownloadFileController.php
@@ -0,0 +1,21 @@
+<?php
+
+class DownloadFileController extends Controller {
+
+    public function __construct()
+    {
+        $this->beforeFilter('verifylogin');
+        $this->beforeFilter('verifyauthorizeduser');
+    }
+
+    public function downloadFile(){
+        if(Input::has("filePath") ){
+            $filePath = Input::get("filePath");
+            $file= Config::get('pga_config.airavata')["experiment-data-absolute-path"] .
"/" . Session::get("username") . "/" . $filePath;
+            $headers = array(
+                'application/octet-stream',
+            );
+            return Response::download($file, 'gaussian.in.com', $headers);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/dbf6db42/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index 4f997d0..1c5e0c3 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -327,21 +327,31 @@ class ExperimentUtilities
         }
     }
 
+    /**
+     * recursively create a long directory path
+     */
+    public static function create_path_recursively($path) {
+        if (is_dir($path)) return true;
+        $prev_path = substr($path, 0, strrpos($path, '/', -2) + 1 );
+        $return = ExperimentUtilities::create_path_recursively($prev_path);
+        return ($return && is_writable($prev_path)) ? mkdir($path) : false;
+    }
 
     public static function create_experiment_folder_path()
     {
         do {
             ExperimentUtilities::$experimentPath = Config::get('pga_config.airavata')['experiment-data-absolute-path']
.
-                "/" . str_replace(' ', '', Session::get('username')) . md5(rand() * time())
. '/';
+                "/" . str_replace(' ', '', Session::get('username')) . "/" . md5(rand() *
time()) . '/';
         } while (is_dir(ExperimentUtilities::$experimentPath)); // if dir already exists,
try again
         // create upload directory
-        if (!mkdir(ExperimentUtilities::$experimentPath)) {
+        if (! ExperimentUtilities::create_path_recursively(ExperimentUtilities::$experimentPath))
{
             CommonUtilities::print_error_message('<p>Error creating upload directory!
             Please try again later or report a bug using the link in the Help menu.</p>');
             $experimentAssemblySuccessful = false;
         }
     }
 
+
     /**
      * Check the uploaded files for errors
      */

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/dbf6db42/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 138f010..8fbd22a 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -206,6 +206,9 @@ Route::post("admin/add-roles-to-user", "AdminController@addRolesToUser");
 
 Route::post("admin/remove-role-from-user", "AdminController@removeRoleFromUser");
 
+Route::get("download-file", "DownloadFileController@downloadFile");
+
+
 //Super Admin Specific calls
 
 Route::post("admin/add-gateway", "AdminController@addGateway");


Mime
View raw message