@@ -13,8 +13,8 @@ var streams = require('stream');
1313
1414
1515nb_api . factory ( 'nbFiles' , [
16- '$http' , '$q' , '$window' , '$timeout' , '$sce' , 'nbAlertify' , '$rootScope' , 'nbClient' , '$location' ,
17- function ( $http , $q , $window , $timeout , $sce , nbAlertify , $rootScope , nbClient , $location ) {
16+ '$http' , '$q' , '$window' , '$timeout' , '$sce' , 'nbAlertify' , '$rootScope' , 'nbClient' , '$location' , 'nbSystem' ,
17+ function ( $http , $q , $window , $timeout , $sce , nbAlertify , $rootScope , nbClient , $location , nbSystem ) {
1818 var $scope = { } ;
1919
2020 $scope . list_files = list_files ;
@@ -33,7 +33,8 @@ nb_api.factory('nbFiles', [
3333 $scope . downloads = [ ] ;
3434 $scope . transfers = [ ] ;
3535 $scope . s3 = null ;
36-
36+ $scope . web_port = 0 ;
37+ $scope . ssl_port = 0 ;
3738 // call first time with empty keys to initialize s3
3839 set_access_keys ( ) ;
3940
@@ -61,7 +62,9 @@ nb_api.factory('nbFiles', [
6162
6263 //update access keys.
6364 //TODO: find more secured approach
64- function set_access_keys ( access_keys ) {
65+ function set_access_keys ( access_keys , web_port , ssl_port ) {
66+ $scope . web_port = web_port ;
67+ $scope . ssl_port = ssl_port ;
6568 if ( ! _ . isEmpty ( access_keys ) ) {
6669 AWS . config . update ( {
6770 accessKeyId : access_keys [ 0 ] . access_key ,
@@ -87,7 +90,13 @@ nb_api.factory('nbFiles', [
8790 // (rest_port ? ':' + rest_port : '')+'/s3';
8891 // var https_endpoint = 'https://127.0.0.1' +
8992 // (rest_ssl_port ? ':' + rest_ssl_port : '')+'/s3';
90- var rest_endpoint = $window . location . protocol + '//' + $window . location . host + '/s3' ;
93+ //var rest_host = ($window.location.host).replace(':'+web_port,'').replace(':'+ssl_port,':443');
94+ var rest_host = ( $window . location . host ) . replace ( ':' + web_port , '' ) . replace ( ':' + ssl_port , '' ) ;
95+
96+ console . log ( 'SYS1:' + web_port + ' host:' + rest_host ) ;
97+
98+ var rest_endpoint = $window . location . protocol + '//' + rest_host ;
99+ rest_endpoint = rest_endpoint . replace ( 'https' , 'http' ) ;
91100 console . log ( 'win:' , $window . location , ":" , rest_endpoint ) ;
92101 $scope . s3 = new AWS . S3 ( {
93102 // endpoint: $window.location.protocol === 'https:' ?
@@ -119,7 +128,7 @@ nb_api.factory('nbFiles', [
119128 return nbClient . client . object_driver_lazy ( ) . get_object_md ( params , cache_miss ) ;
120129 } )
121130 . then ( function ( res ) {
122- console . log ( 'FILE' , res ) ;
131+ console . log ( 'FILE' , res , params . key ) ;
123132 var file_info = make_file_info ( {
124133 key : params . key ,
125134 info : res
@@ -129,6 +138,8 @@ nb_api.factory('nbFiles', [
129138 Bucket : params . bucket ,
130139 Key : params . key
131140 } ) ;
141+ url = url . replace ( ':' + $scope . web_port , '' ) . replace ( ':' + $scope . ssl_port , ':443' ) ;
142+
132143 console . log ( 'urlll:' , url ) ;
133144 file_info . url = url ;
134145 return file_info ;
0 commit comments